Skip to content

Commit 100f804

Browse files
authored
Merge pull request #60309 from nextcloud/backport/60262/stable33
[stable33] fix(http-client): detect brotli support via libcurl, not PHP extension
2 parents 8e8e8ba + 78cb8c3 commit 100f804

2 files changed

Lines changed: 5 additions & 5 deletions

File tree

lib/private/Http/Client/Client.php

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

tests/lib/Http/Client/ClientTest.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -284,7 +284,7 @@ private function setUpDefaultRequestOptions(): void {
284284
$this->serverVersion->method('getVersionString')
285285
->willReturn('123.45.6');
286286

287-
$acceptEnc = function_exists('brotli_uncompress') ? 'br, gzip' : 'gzip';
287+
$acceptEnc = (((curl_version()['features'] ?? 0) & CURL_VERSION_BROTLI) === CURL_VERSION_BROTLI) ? 'br, gzip' : 'gzip';
288288
$this->defaultRequestOptions = [
289289
'verify' => '/my/path.crt',
290290
'proxy' => [
@@ -488,7 +488,7 @@ public function testSetDefaultOptionsWithNotInstalled(): void {
488488
$this->serverVersion->method('getVersionString')
489489
->willReturn('123.45.6');
490490

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

493493
$this->assertEquals([
494494
'verify' => \OC::$SERVERROOT . '/resources/config/ca-bundle.crt',
@@ -544,7 +544,7 @@ public function testSetDefaultOptionsWithProxy(): void {
544544
$this->serverVersion->method('getVersionString')
545545
->willReturn('123.45.6');
546546

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

549549
$this->assertEquals([
550550
'verify' => '/my/path.crt',
@@ -604,7 +604,7 @@ public function testSetDefaultOptionsWithProxyAndExclude(): void {
604604
$this->serverVersion->method('getVersionString')
605605
->willReturn('123.45.6');
606606

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

609609
$this->assertEquals([
610610
'verify' => '/my/path.crt',

0 commit comments

Comments
 (0)