From: Morris Jobke Date: Tue, 19 May 2020 21:04:51 +0000 (+0200) Subject: Compress the appstore requests by default X-Git-Tag: v16.0.11RC1~9^2 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=758f34351363ec87af445add8bed07a7a2aea4d0;p=nextcloud-server.git Compress the appstore requests by default In test it reduced the transfered data from 5 MB to 2 MB. This should reduce the load on the appstore significantly. Signed-off-by: Morris Jobke --- diff --git a/lib/private/App/AppStore/Fetcher/Fetcher.php b/lib/private/App/AppStore/Fetcher/Fetcher.php index 96e0d93e27f..8b9f91812ba 100644 --- a/lib/private/App/AppStore/Fetcher/Fetcher.php +++ b/lib/private/App/AppStore/Fetcher/Fetcher.php @@ -96,12 +96,11 @@ abstract class Fetcher { $options = [ 'timeout' => 10, + 'headers' => ['Accept-Encoding' => 'gzip'], ]; if ($ETag !== '') { - $options['headers'] = [ - 'If-None-Match' => $ETag, - ]; + $options['headers']['If-None-Match'] = $ETag; } $client = $this->clientService->newClient(); diff --git a/tests/lib/App/AppStore/Fetcher/FetcherBase.php b/tests/lib/App/AppStore/Fetcher/FetcherBase.php index d3339faad43..936f18783d1 100644 --- a/tests/lib/App/AppStore/Fetcher/FetcherBase.php +++ b/tests/lib/App/AppStore/Fetcher/FetcherBase.php @@ -244,7 +244,15 @@ abstract class FetcherBase extends TestCase { $client ->expects($this->once()) ->method('get') - ->with($this->endpoint) + ->with( + $this->equalTo($this->endpoint), + $this->equalTo([ + 'timeout' => 10, + 'headers' => [ + 'Accept-Encoding' => 'gzip', + ] + ]) + ) ->willReturn($response); $response ->expects($this->once()) @@ -332,7 +340,15 @@ abstract class FetcherBase extends TestCase { $client ->expects($this->once()) ->method('get') - ->with($this->endpoint) + ->with( + $this->equalTo($this->endpoint), + $this->equalTo([ + 'timeout' => 10, + 'headers' => [ + 'Accept-Encoding' => 'gzip', + ] + ]) + ) ->willReturn($response); $response ->expects($this->once()) @@ -415,7 +431,15 @@ abstract class FetcherBase extends TestCase { $client ->expects($this->once()) ->method('get') - ->with($this->endpoint) + ->with( + $this->equalTo($this->endpoint), + $this->equalTo([ + 'timeout' => 10, + 'headers' => [ + 'Accept-Encoding' => 'gzip', + ] + ]) + ) ->willReturn($response); $response ->expects($this->once()) @@ -480,7 +504,15 @@ abstract class FetcherBase extends TestCase { $client ->expects($this->once()) ->method('get') - ->with($this->endpoint) + ->with( + $this->equalTo($this->endpoint), + $this->equalTo([ + 'timeout' => 10, + 'headers' => [ + 'Accept-Encoding' => 'gzip', + ] + ]) + ) ->willThrowException(new \Exception()); $this->assertSame([], $this->fetcher->get()); @@ -537,7 +569,8 @@ abstract class FetcherBase extends TestCase { $this->equalTo([ 'timeout' => 10, 'headers' => [ - 'If-None-Match' => '"myETag"' + 'Accept-Encoding' => 'gzip', + 'If-None-Match' => '"myETag"', ] ]) )->willReturn($response); @@ -609,6 +642,7 @@ abstract class FetcherBase extends TestCase { $this->equalTo([ 'timeout' => 10, 'headers' => [ + 'Accept-Encoding' => 'gzip', 'If-None-Match' => '"myETag"', ] ]) @@ -695,6 +729,9 @@ abstract class FetcherBase extends TestCase { $this->equalTo($this->endpoint), $this->equalTo([ 'timeout' => 10, + 'headers' => [ + 'Accept-Encoding' => 'gzip', + ], ]) ) ->willReturn($response);