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
Next Next commit
Allow gzip encoded requests by default
Signed-off-by: Morris Jobke <[email protected]>
  • Loading branch information
MorrisJobke committed May 20, 2020
commit 8bcd1c31da7a02e78435aa49508ed3787b11867d
4 changes: 4 additions & 0 deletions lib/private/Http/Client/Client.php
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,10 @@ private function buildRequestOptions(array $options): array {
$options[RequestOptions::HEADERS]['User-Agent'] = 'Nextcloud Server Crawler';
}

if (!isset($options[RequestOptions::HEADERS]['Accept-Encoding'])) {
$options[RequestOptions::HEADERS]['Accept-Encoding'] = 'gzip';
}

return $options;
}

Expand Down
10 changes: 7 additions & 3 deletions tests/lib/Http/Client/ClientTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -292,6 +292,7 @@ private function setUpDefaultRequestOptions(): void {
],
'headers' => [
'User-Agent' => 'Nextcloud Server Crawler',
'Accept-Encoding' => 'gzip',
],
'timeout' => 30,
];
Expand Down Expand Up @@ -467,7 +468,8 @@ public function testSetDefaultOptionsWithNotInstalled(): void {
$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', [[]]));
Expand Down Expand Up @@ -502,7 +504,8 @@ public function testSetDefaultOptionsWithProxy(): void {
'https' => 'foo'
],
'headers' => [
'User-Agent' => 'Nextcloud Server Crawler'
'User-Agent' => 'Nextcloud Server Crawler',
'Accept-Encoding' => 'gzip',
],
'timeout' => 30,
], self::invokePrivate($this->client, 'buildRequestOptions', [[]]));
Expand Down Expand Up @@ -538,7 +541,8 @@ public function testSetDefaultOptionsWithProxyAndExclude(): void {
'no' => ['bar']
],
'headers' => [
'User-Agent' => 'Nextcloud Server Crawler'
'User-Agent' => 'Nextcloud Server Crawler',
'Accept-Encoding' => 'gzip',
],
'timeout' => 30,
], self::invokePrivate($this->client, 'buildRequestOptions', [[]]));
Expand Down