Skip to content

Commit 04bd872

Browse files
committed
style(http-client): use explicit bitmask comparison for CURL_VERSION_BROTLI
Signed-off-by: ernolf <raphael.gradenwitz@googlemail.com>
1 parent c1cd4de commit 04bd872

2 files changed

Lines changed: 6 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 ((curl_version()['features'] ?? 0) & CURL_VERSION_BROTLI) {
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: 5 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 = ((curl_version()['features'] ?? 0) & CURL_VERSION_BROTLI) ? '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 = ((curl_version()['features'] ?? 0) & CURL_VERSION_BROTLI) ? '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 = ((curl_version()['features'] ?? 0) & CURL_VERSION_BROTLI) ? '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 = ((curl_version()['features'] ?? 0) & CURL_VERSION_BROTLI) ? '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,7 +680,7 @@ 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) ? 'br, gzip' : 'gzip';
683+
$acceptEnc = (((curl_version()['features'] ?? 0) & CURL_VERSION_BROTLI) === CURL_VERSION_BROTLI) ? 'br, gzip' : 'gzip';
684684
$this->assertEquals([
685685
'verify' => '/my/path.crt',
686686
'headers' => [

0 commit comments

Comments
 (0)