Allow gzip encoded requests by default

Signed-off-by: Morris Jobke <hey@morrisjobke.de>
This commit is contained in:
Morris Jobke 2020-05-20 11:08:27 +02:00
parent 526905cfc2
commit 8bcd1c31da
No known key found for this signature in database
GPG Key ID: FE03C3A163FEDE68
2 changed files with 11 additions and 3 deletions

View 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;
}

View 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', [[]]));