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 <hey@morrisjobke.de>
This commit is contained in:
Morris Jobke 2020-05-19 23:04:51 +02:00 committed by backportbot[bot]
parent 5c0f06b259
commit 745667e426
2 changed files with 44 additions and 8 deletions

View File

@ -98,12 +98,11 @@ abstract class Fetcher {
$options = [ $options = [
'timeout' => 10, 'timeout' => 10,
'headers' => ['Accept-Encoding' => 'gzip'],
]; ];
if ($ETag !== '') { if ($ETag !== '') {
$options['headers'] = [ $options['headers']['If-None-Match'] = $ETag;
'If-None-Match' => $ETag,
];
} }
$client = $this->clientService->newClient(); $client = $this->clientService->newClient();

View File

@ -249,7 +249,15 @@ abstract class FetcherBase extends TestCase {
$client $client
->expects($this->once()) ->expects($this->once())
->method('get') ->method('get')
->with($this->endpoint) ->with(
$this->equalTo($this->endpoint),
$this->equalTo([
'timeout' => 10,
'headers' => [
'Accept-Encoding' => 'gzip',
]
])
)
->willReturn($response); ->willReturn($response);
$response $response
->expects($this->once()) ->expects($this->once())
@ -342,7 +350,15 @@ abstract class FetcherBase extends TestCase {
$client $client
->expects($this->once()) ->expects($this->once())
->method('get') ->method('get')
->with($this->endpoint) ->with(
$this->equalTo($this->endpoint),
$this->equalTo([
'timeout' => 10,
'headers' => [
'Accept-Encoding' => 'gzip',
]
])
)
->willReturn($response); ->willReturn($response);
$response $response
->expects($this->once()) ->expects($this->once())
@ -430,7 +446,15 @@ abstract class FetcherBase extends TestCase {
$client $client
->expects($this->once()) ->expects($this->once())
->method('get') ->method('get')
->with($this->endpoint) ->with(
$this->equalTo($this->endpoint),
$this->equalTo([
'timeout' => 10,
'headers' => [
'Accept-Encoding' => 'gzip',
]
])
)
->willReturn($response); ->willReturn($response);
$response $response
->expects($this->once()) ->expects($this->once())
@ -495,7 +519,15 @@ abstract class FetcherBase extends TestCase {
$client $client
->expects($this->once()) ->expects($this->once())
->method('get') ->method('get')
->with($this->endpoint) ->with(
$this->equalTo($this->endpoint),
$this->equalTo([
'timeout' => 10,
'headers' => [
'Accept-Encoding' => 'gzip',
]
])
)
->willThrowException(new \Exception()); ->willThrowException(new \Exception());
$this->assertSame([], $this->fetcher->get()); $this->assertSame([], $this->fetcher->get());
@ -552,7 +584,8 @@ abstract class FetcherBase extends TestCase {
$this->equalTo([ $this->equalTo([
'timeout' => 10, 'timeout' => 10,
'headers' => [ 'headers' => [
'If-None-Match' => '"myETag"' 'Accept-Encoding' => 'gzip',
'If-None-Match' => '"myETag"',
] ]
]) ])
)->willReturn($response); )->willReturn($response);
@ -624,6 +657,7 @@ abstract class FetcherBase extends TestCase {
$this->equalTo([ $this->equalTo([
'timeout' => 10, 'timeout' => 10,
'headers' => [ 'headers' => [
'Accept-Encoding' => 'gzip',
'If-None-Match' => '"myETag"', 'If-None-Match' => '"myETag"',
] ]
]) ])
@ -710,6 +744,9 @@ abstract class FetcherBase extends TestCase {
$this->equalTo($this->endpoint), $this->equalTo($this->endpoint),
$this->equalTo([ $this->equalTo([
'timeout' => 10, 'timeout' => 10,
'headers' => [
'Accept-Encoding' => 'gzip',
],
]) ])
) )
->willReturn($response); ->willReturn($response);