]> source.dussan.org Git - nextcloud-server.git/commitdiff
Allow gzip encoded requests by default
authorMorris Jobke <hey@morrisjobke.de>
Wed, 20 May 2020 09:08:27 +0000 (11:08 +0200)
committerMorris Jobke <hey@morrisjobke.de>
Wed, 20 May 2020 11:37:28 +0000 (13:37 +0200)
Signed-off-by: Morris Jobke <hey@morrisjobke.de>
lib/private/Http/Client/Client.php
tests/lib/Http/Client/ClientTest.php

index d19f1124a23d3bcca72ebec49ef97ef866e5de8b..af43df6365f8c268ddb2fa786b4d694cd4fa5a13 100644 (file)
@@ -89,6 +89,10 @@ class Client implements IClient {
                        $options[RequestOptions::HEADERS]['User-Agent'] = 'Nextcloud Server Crawler';
                }
 
+               if (!isset($options[RequestOptions::HEADERS]['Accept-Encoding'])) {
+                       $options[RequestOptions::HEADERS]['Accept-Encoding'] = 'gzip';
+               }
+
                return $options;
        }
 
index b136a0ca30087deff4420728c478d8655bcf9228..a0c4d75c1bd8496f6114a6b3ec548842aa60e775 100644 (file)
@@ -292,6 +292,7 @@ class ClientTest extends \Test\TestCase {
                        ],
                        'headers' => [
                                'User-Agent' => 'Nextcloud Server Crawler',
+                               'Accept-Encoding' => 'gzip',
                        ],
                        'timeout' => 30,
                ];
@@ -467,7 +468,8 @@ class ClientTest extends \Test\TestCase {
                $this->assertEquals([
                        'verify' => \OC::$SERVERROOT . '/resources/config/ca-bundle.crt',
                        'headers' => [
-                               'User-Agent' => 'Nextcloud Server Crawler'
+                               'User-Agent' => 'Nextcloud Server Crawler',
+                               'Accept-Encoding' => 'gzip',
                        ],
                        'timeout' => 30,
                ], self::invokePrivate($this->client, 'buildRequestOptions', [[]]));
@@ -502,7 +504,8 @@ class ClientTest extends \Test\TestCase {
                                'https' => 'foo'
                        ],
                        'headers' => [
-                               'User-Agent' => 'Nextcloud Server Crawler'
+                               'User-Agent' => 'Nextcloud Server Crawler',
+                               'Accept-Encoding' => 'gzip',
                        ],
                        'timeout' => 30,
                ], self::invokePrivate($this->client, 'buildRequestOptions', [[]]));
@@ -538,7 +541,8 @@ class ClientTest extends \Test\TestCase {
                                'no' => ['bar']
                        ],
                        'headers' => [
-                               'User-Agent' => 'Nextcloud Server Crawler'
+                               'User-Agent' => 'Nextcloud Server Crawler',
+                               'Accept-Encoding' => 'gzip',
                        ],
                        'timeout' => 30,
                ], self::invokePrivate($this->client, 'buildRequestOptions', [[]]));