From c1cd4de1cd85a034af29d921007f566d6a9e6cb1 Mon Sep 17 00:00:00 2001 From: ernolf Date: Sat, 9 May 2026 03:23:27 +0200 Subject: [PATCH 1/2] fix(http-client): detect brotli support via libcurl, not PHP extension - Fixes a regression introduced in #55433. Signed-off-by: ernolf --- lib/private/Http/Client/Client.php | 2 +- tests/lib/Http/Client/ClientTest.php | 11 ++++++----- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/lib/private/Http/Client/Client.php b/lib/private/Http/Client/Client.php index 0a42ace17c0b4..a5bc7cb717ff8 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) { $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..6f1674c54411f 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) ? '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) ? '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) ? '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) ? '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) ? 'br, gzip' : 'gzip'; $this->assertEquals([ 'verify' => '/my/path.crt', 'headers' => [ 'User-Agent' => $userAgent, - 'Accept-Encoding' => 'gzip', + 'Accept-Encoding' => $acceptEnc, ], 'timeout' => 30, 'nextcloud' => [ From 04bd872fd291406d7ffbf11f828c665e4825353d Mon Sep 17 00:00:00 2001 From: ernolf Date: Mon, 11 May 2026 14:06:57 +0200 Subject: [PATCH 2/2] style(http-client): use explicit bitmask comparison for CURL_VERSION_BROTLI Signed-off-by: ernolf --- lib/private/Http/Client/Client.php | 2 +- tests/lib/Http/Client/ClientTest.php | 10 +++++----- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/lib/private/Http/Client/Client.php b/lib/private/Http/Client/Client.php index a5bc7cb717ff8..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 ((curl_version()['features'] ?? 0) & CURL_VERSION_BROTLI) { + 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 6f1674c54411f..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 = ((curl_version()['features'] ?? 0) & CURL_VERSION_BROTLI) ? '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 = ((curl_version()['features'] ?? 0) & CURL_VERSION_BROTLI) ? '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 = ((curl_version()['features'] ?? 0) & CURL_VERSION_BROTLI) ? '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 = ((curl_version()['features'] ?? 0) & CURL_VERSION_BROTLI) ? 'br, gzip' : 'gzip'; + $acceptEnc = (((curl_version()['features'] ?? 0) & CURL_VERSION_BROTLI) === CURL_VERSION_BROTLI) ? 'br, gzip' : 'gzip'; $this->assertEquals([ 'verify' => '/my/path.crt', @@ -680,7 +680,7 @@ public function testSetServerUrlInUserAgent(string $url, string $userAgent): voi $this->serverVersion->method('getVersionString') ->willReturn('123.45.6'); - $acceptEnc = ((curl_version()['features'] ?? 0) & CURL_VERSION_BROTLI) ? 'br, gzip' : 'gzip'; + $acceptEnc = (((curl_version()['features'] ?? 0) & CURL_VERSION_BROTLI) === CURL_VERSION_BROTLI) ? 'br, gzip' : 'gzip'; $this->assertEquals([ 'verify' => '/my/path.crt', 'headers' => [