Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
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 <[email protected]>
  • Loading branch information
MorrisJobke committed May 20, 2020
commit 758f34351363ec87af445add8bed07a7a2aea4d0
5 changes: 2 additions & 3 deletions lib/private/App/AppStore/Fetcher/Fetcher.php
Original file line number Diff line number Diff line change
Expand Up @@ -96,12 +96,11 @@ protected function fetch($ETag, $content) {

$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();
Expand Down
47 changes: 42 additions & 5 deletions tests/lib/App/AppStore/Fetcher/FetcherBase.php
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,15 @@ public function testGetWithAlreadyExistingFileAndOutdatedTimestamp() {
$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())
Expand Down Expand Up @@ -332,7 +340,15 @@ public function testGetWithAlreadyExistingFileAndNoVersion() {
$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())
Expand Down Expand Up @@ -415,7 +431,15 @@ public function testGetWithAlreadyExistingFileAndOutdatedVersion() {
$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())
Expand Down Expand Up @@ -480,7 +504,15 @@ public function testGetWithExceptionInClient() {
$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());
Expand Down Expand Up @@ -537,7 +569,8 @@ public function testGetMatchingETag() {
$this->equalTo([
'timeout' => 10,
'headers' => [
'If-None-Match' => '"myETag"'
'Accept-Encoding' => 'gzip',
'If-None-Match' => '"myETag"',
]
])
)->willReturn($response);
Expand Down Expand Up @@ -609,6 +642,7 @@ public function testGetNoMatchingETag() {
$this->equalTo([
'timeout' => 10,
'headers' => [
'Accept-Encoding' => 'gzip',
'If-None-Match' => '"myETag"',
]
])
Expand Down Expand Up @@ -695,6 +729,9 @@ public function testFetchAfterUpgradeNoETag() {
$this->equalTo($this->endpoint),
$this->equalTo([
'timeout' => 10,
'headers' => [
'Accept-Encoding' => 'gzip',
],
])
)
->willReturn($response);
Expand Down