Skip to content

Commit 6ffde12

Browse files
committed
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]>
1 parent 3e0d8df commit 6ffde12

File tree

2 files changed

+44
-8
lines changed

2 files changed

+44
-8
lines changed

lib/private/App/AppStore/Fetcher/Fetcher.php

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -98,12 +98,11 @@ protected function fetch($ETag, $content) {
9898

9999
$options = [
100100
'timeout' => 10,
101+
'headers' => ['Accept-Encoding' => 'gzip'],
101102
];
102103

103104
if ($ETag !== '') {
104-
$options['headers'] = [
105-
'If-None-Match' => $ETag,
106-
];
105+
$options['headers']['If-None-Match'] = $ETag;
107106
}
108107

109108
$client = $this->clientService->newClient();

tests/lib/App/AppStore/Fetcher/FetcherBase.php

Lines changed: 42 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -249,7 +249,15 @@ public function testGetWithAlreadyExistingFileAndOutdatedTimestamp() {
249249
$client
250250
->expects($this->once())
251251
->method('get')
252-
->with($this->endpoint)
252+
->with(
253+
$this->equalTo($this->endpoint),
254+
$this->equalTo([
255+
'timeout' => 10,
256+
'headers' => [
257+
'Accept-Encoding' => 'gzip',
258+
]
259+
])
260+
)
253261
->willReturn($response);
254262
$response
255263
->expects($this->once())
@@ -342,7 +350,15 @@ public function testGetWithAlreadyExistingFileAndNoVersion() {
342350
$client
343351
->expects($this->once())
344352
->method('get')
345-
->with($this->endpoint)
353+
->with(
354+
$this->equalTo($this->endpoint),
355+
$this->equalTo([
356+
'timeout' => 10,
357+
'headers' => [
358+
'Accept-Encoding' => 'gzip',
359+
]
360+
])
361+
)
346362
->willReturn($response);
347363
$response
348364
->expects($this->once())
@@ -430,7 +446,15 @@ public function testGetWithAlreadyExistingFileAndOutdatedVersion() {
430446
$client
431447
->expects($this->once())
432448
->method('get')
433-
->with($this->endpoint)
449+
->with(
450+
$this->equalTo($this->endpoint),
451+
$this->equalTo([
452+
'timeout' => 10,
453+
'headers' => [
454+
'Accept-Encoding' => 'gzip',
455+
]
456+
])
457+
)
434458
->willReturn($response);
435459
$response
436460
->expects($this->once())
@@ -495,7 +519,15 @@ public function testGetWithExceptionInClient() {
495519
$client
496520
->expects($this->once())
497521
->method('get')
498-
->with($this->endpoint)
522+
->with(
523+
$this->equalTo($this->endpoint),
524+
$this->equalTo([
525+
'timeout' => 10,
526+
'headers' => [
527+
'Accept-Encoding' => 'gzip',
528+
]
529+
])
530+
)
499531
->willThrowException(new \Exception());
500532

501533
$this->assertSame([], $this->fetcher->get());
@@ -552,7 +584,8 @@ public function testGetMatchingETag() {
552584
$this->equalTo([
553585
'timeout' => 10,
554586
'headers' => [
555-
'If-None-Match' => '"myETag"'
587+
'Accept-Encoding' => 'gzip',
588+
'If-None-Match' => '"myETag"',
556589
]
557590
])
558591
)->willReturn($response);
@@ -624,6 +657,7 @@ public function testGetNoMatchingETag() {
624657
$this->equalTo([
625658
'timeout' => 10,
626659
'headers' => [
660+
'Accept-Encoding' => 'gzip',
627661
'If-None-Match' => '"myETag"',
628662
]
629663
])
@@ -710,6 +744,9 @@ public function testFetchAfterUpgradeNoETag() {
710744
$this->equalTo($this->endpoint),
711745
$this->equalTo([
712746
'timeout' => 10,
747+
'headers' => [
748+
'Accept-Encoding' => 'gzip',
749+
],
713750
])
714751
)
715752
->willReturn($response);

0 commit comments

Comments
 (0)