Skip to content

Commit 94c25e2

Browse files
Merge pull request #60262 from nextcloud/ernolf/fix/brotli-detection
2 parents df2e3e0 + 04bd872 commit 94c25e2

2 files changed

Lines changed: 7 additions & 6 deletions

File tree

lib/private/Http/Client/Client.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ private function buildRequestOptions(array $options): array {
8888
$headers = $options[RequestOptions::HEADERS] ?? [];
8989
if (!isset($headers['Accept-Encoding'])) {
9090
$acceptEnc = 'gzip';
91-
if (function_exists('brotli_uncompress')) {
91+
if (((curl_version()['features'] ?? 0) & CURL_VERSION_BROTLI) === CURL_VERSION_BROTLI) {
9292
$acceptEnc = 'br, ' . $acceptEnc;
9393
}
9494
$options[RequestOptions::HEADERS] = $headers; // ensure headers are present

tests/lib/Http/Client/ClientTest.php

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -288,7 +288,7 @@ private function setUpDefaultRequestOptions(): void {
288288
$this->serverVersion->method('getVersionString')
289289
->willReturn('123.45.6');
290290

291-
$acceptEnc = function_exists('brotli_uncompress') ? 'br, gzip' : 'gzip';
291+
$acceptEnc = (((curl_version()['features'] ?? 0) & CURL_VERSION_BROTLI) === CURL_VERSION_BROTLI) ? 'br, gzip' : 'gzip';
292292
$this->defaultRequestOptions = [
293293
'verify' => '/my/path.crt',
294294
'proxy' => [
@@ -495,7 +495,7 @@ public function testSetDefaultOptionsWithNotInstalled(): void {
495495
$this->serverVersion->method('getVersionString')
496496
->willReturn('123.45.6');
497497

498-
$acceptEnc = function_exists('brotli_uncompress') ? 'br, gzip' : 'gzip';
498+
$acceptEnc = (((curl_version()['features'] ?? 0) & CURL_VERSION_BROTLI) === CURL_VERSION_BROTLI) ? 'br, gzip' : 'gzip';
499499

500500
$this->assertEquals([
501501
'verify' => \OC::$SERVERROOT . '/resources/config/ca-bundle.crt',
@@ -553,7 +553,7 @@ public function testSetDefaultOptionsWithProxy(): void {
553553
$this->serverVersion->method('getVersionString')
554554
->willReturn('123.45.6');
555555

556-
$acceptEnc = function_exists('brotli_uncompress') ? 'br, gzip' : 'gzip';
556+
$acceptEnc = (((curl_version()['features'] ?? 0) & CURL_VERSION_BROTLI) === CURL_VERSION_BROTLI) ? 'br, gzip' : 'gzip';
557557

558558
$this->assertEquals([
559559
'verify' => '/my/path.crt',
@@ -615,7 +615,7 @@ public function testSetDefaultOptionsWithProxyAndExclude(): void {
615615
$this->serverVersion->method('getVersionString')
616616
->willReturn('123.45.6');
617617

618-
$acceptEnc = function_exists('brotli_uncompress') ? 'br, gzip' : 'gzip';
618+
$acceptEnc = (((curl_version()['features'] ?? 0) & CURL_VERSION_BROTLI) === CURL_VERSION_BROTLI) ? 'br, gzip' : 'gzip';
619619

620620
$this->assertEquals([
621621
'verify' => '/my/path.crt',
@@ -680,11 +680,12 @@ public function testSetServerUrlInUserAgent(string $url, string $userAgent): voi
680680
$this->serverVersion->method('getVersionString')
681681
->willReturn('123.45.6');
682682

683+
$acceptEnc = (((curl_version()['features'] ?? 0) & CURL_VERSION_BROTLI) === CURL_VERSION_BROTLI) ? 'br, gzip' : 'gzip';
683684
$this->assertEquals([
684685
'verify' => '/my/path.crt',
685686
'headers' => [
686687
'User-Agent' => $userAgent,
687-
'Accept-Encoding' => 'gzip',
688+
'Accept-Encoding' => $acceptEnc,
688689
],
689690
'timeout' => 30,
690691
'nextcloud' => [

0 commit comments

Comments
 (0)