]> source.dussan.org Git - nextcloud-server.git/commitdiff
Compress the appstore requests by default 21050/head
authorMorris Jobke <hey@morrisjobke.de>
Tue, 19 May 2020 21:04:51 +0000 (23:04 +0200)
committerMorris Jobke <hey@morrisjobke.de>
Wed, 20 May 2020 07:51:07 +0000 (09:51 +0200)
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>
lib/private/App/AppStore/Fetcher/Fetcher.php
tests/lib/App/AppStore/Fetcher/FetcherBase.php

index bb39637891f2ca65681a8eb2a398ee0b67ca1f25..c109bacf1358bd962c3aec937ba5f65b1bffde8e 100644 (file)
@@ -98,12 +98,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();
index 2e04f22760e3588746aace5e5b88da383a67ba63..45f3f22b9d42587752a82f54e5bfd174110c1ef1 100644 (file)
@@ -249,7 +249,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())
@@ -342,7 +350,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())
@@ -430,7 +446,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())
@@ -495,7 +519,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());
@@ -552,7 +584,8 @@ abstract class FetcherBase extends TestCase {
                                $this->equalTo([
                                        'timeout' => 10,
                                        'headers' => [
-                                               'If-None-Match' => '"myETag"'
+                                               'Accept-Encoding' => 'gzip',
+                                               'If-None-Match' => '"myETag"',
                                        ]
                                ])
                        )->willReturn($response);
@@ -624,6 +657,7 @@ abstract class FetcherBase extends TestCase {
                                $this->equalTo([
                                        'timeout' => 10,
                                        'headers' => [
+                                               'Accept-Encoding' => 'gzip',
                                                'If-None-Match' => '"myETag"',
                                        ]
                                ])
@@ -710,6 +744,9 @@ abstract class FetcherBase extends TestCase {
                                $this->equalTo($this->endpoint),
                                $this->equalTo([
                                        'timeout' => 10,
+                                       'headers' => [
+                                               'Accept-Encoding' => 'gzip',
+                                       ],
                                ])
                        )
                        ->willReturn($response);