diff --git a/lib/private/Http/Client/Client.php b/lib/private/Http/Client/Client.php index 0a42ace17c0b4..10f07f51e8ab9 100644 --- a/lib/private/Http/Client/Client.php +++ b/lib/private/Http/Client/Client.php @@ -88,7 +88,7 @@ private function buildRequestOptions(array $options): array { $headers = $options[RequestOptions::HEADERS] ?? []; if (!isset($headers['Accept-Encoding'])) { $acceptEnc = 'gzip'; - if (function_exists('brotli_uncompress')) { + if (((curl_version()['features'] ?? 0) & CURL_VERSION_BROTLI) === CURL_VERSION_BROTLI) { $acceptEnc = 'br, ' . $acceptEnc; } $options[RequestOptions::HEADERS] = $headers; // ensure headers are present diff --git a/tests/lib/Http/Client/ClientTest.php b/tests/lib/Http/Client/ClientTest.php index c6fa45eb318f8..8bf90ea95bda0 100644 --- a/tests/lib/Http/Client/ClientTest.php +++ b/tests/lib/Http/Client/ClientTest.php @@ -288,7 +288,7 @@ private function setUpDefaultRequestOptions(): void { $this->serverVersion->method('getVersionString') ->willReturn('123.45.6'); - $acceptEnc = function_exists('brotli_uncompress') ? 'br, gzip' : 'gzip'; + $acceptEnc = (((curl_version()['features'] ?? 0) & CURL_VERSION_BROTLI) === CURL_VERSION_BROTLI) ? 'br, gzip' : 'gzip'; $this->defaultRequestOptions = [ 'verify' => '/my/path.crt', 'proxy' => [ @@ -495,7 +495,7 @@ public function testSetDefaultOptionsWithNotInstalled(): void { $this->serverVersion->method('getVersionString') ->willReturn('123.45.6'); - $acceptEnc = function_exists('brotli_uncompress') ? 'br, gzip' : 'gzip'; + $acceptEnc = (((curl_version()['features'] ?? 0) & CURL_VERSION_BROTLI) === CURL_VERSION_BROTLI) ? 'br, gzip' : 'gzip'; $this->assertEquals([ 'verify' => \OC::$SERVERROOT . '/resources/config/ca-bundle.crt', @@ -553,7 +553,7 @@ public function testSetDefaultOptionsWithProxy(): void { $this->serverVersion->method('getVersionString') ->willReturn('123.45.6'); - $acceptEnc = function_exists('brotli_uncompress') ? 'br, gzip' : 'gzip'; + $acceptEnc = (((curl_version()['features'] ?? 0) & CURL_VERSION_BROTLI) === CURL_VERSION_BROTLI) ? 'br, gzip' : 'gzip'; $this->assertEquals([ 'verify' => '/my/path.crt', @@ -615,7 +615,7 @@ public function testSetDefaultOptionsWithProxyAndExclude(): void { $this->serverVersion->method('getVersionString') ->willReturn('123.45.6'); - $acceptEnc = function_exists('brotli_uncompress') ? 'br, gzip' : 'gzip'; + $acceptEnc = (((curl_version()['features'] ?? 0) & CURL_VERSION_BROTLI) === CURL_VERSION_BROTLI) ? 'br, gzip' : 'gzip'; $this->assertEquals([ 'verify' => '/my/path.crt', @@ -680,11 +680,12 @@ public function testSetServerUrlInUserAgent(string $url, string $userAgent): voi $this->serverVersion->method('getVersionString') ->willReturn('123.45.6'); + $acceptEnc = (((curl_version()['features'] ?? 0) & CURL_VERSION_BROTLI) === CURL_VERSION_BROTLI) ? 'br, gzip' : 'gzip'; $this->assertEquals([ 'verify' => '/my/path.crt', 'headers' => [ 'User-Agent' => $userAgent, - 'Accept-Encoding' => 'gzip', + 'Accept-Encoding' => $acceptEnc, ], 'timeout' => 30, 'nextcloud' => [