@@ -276,6 +276,13 @@ private function setUpDefaultRequestOptions(): void {
276276 ->with ()
277277 ->willReturn ('/my/path.crt ' );
278278
279+ $ acceptEnc = function_exists ('brotli_uncompress ' ) ? 'br, gzip ' : 'gzip ' ;
280+
281+ // compute curl http version hint like in production code
282+ $ curlVersion = \defined ('CURL_HTTP_VERSION_2TLS ' )
283+ ? \CURL_HTTP_VERSION_2TLS
284+ : (\defined ('CURL_HTTP_VERSION_2_0 ' ) ? \CURL_HTTP_VERSION_2_0 : \CURL_HTTP_VERSION_NONE );
285+
279286 $ this ->defaultRequestOptions = [
280287 'verify ' => '/my/path.crt ' ,
281288 'proxy ' => [
@@ -284,12 +291,16 @@ private function setUpDefaultRequestOptions(): void {
284291 ],
285292 'headers ' => [
286293 'User-Agent ' => 'Nextcloud Server Crawler ' ,
287- 'Accept-Encoding ' => ' gzip ' ,
294+ 'Accept-Encoding ' => $ acceptEnc ,
288295 ],
289296 'timeout ' => 30 ,
290297 'nextcloud ' => [
291298 'allow_local_address ' => true ,
292299 ],
300+ 'version ' => '2.0 ' ,
301+ 'curl ' => [
302+ \CURLOPT_HTTP_VERSION => $ curlVersion ,
303+ ],
293304 ];
294305 }
295306
@@ -466,11 +477,18 @@ public function testSetDefaultOptionsWithNotInstalled(): void {
466477 ->expects ($ this ->never ())
467478 ->method ('listCertificates ' );
468479
480+ $ acceptEnc = function_exists ('brotli_uncompress ' ) ? 'br, gzip ' : 'gzip ' ;
481+
482+ // compute curl http version hint like in production code
483+ $ curlVersion = \defined ('CURL_HTTP_VERSION_2TLS ' )
484+ ? \CURL_HTTP_VERSION_2TLS
485+ : (\defined ('CURL_HTTP_VERSION_2_0 ' ) ? \CURL_HTTP_VERSION_2_0 : \CURL_HTTP_VERSION_NONE );
486+
469487 $ this ->assertEquals ([
470488 'verify ' => \OC ::$ SERVERROOT . '/resources/config/ca-bundle.crt ' ,
471489 'headers ' => [
472490 'User-Agent ' => 'Nextcloud Server Crawler ' ,
473- 'Accept-Encoding ' => ' gzip ' ,
491+ 'Accept-Encoding ' => $ acceptEnc ,
474492 ],
475493 'timeout ' => 30 ,
476494 'nextcloud ' => [
@@ -484,6 +502,10 @@ public function testSetDefaultOptionsWithNotInstalled(): void {
484502 ): void {
485503 },
486504 ],
505+ 'version ' => '2.0 ' ,
506+ 'curl ' => [
507+ \CURLOPT_HTTP_VERSION => $ curlVersion ,
508+ ],
487509 ], self ::invokePrivate ($ this ->client , 'buildRequestOptions ' , [[]]));
488510 }
489511
@@ -513,6 +535,13 @@ public function testSetDefaultOptionsWithProxy(): void {
513535 ->with ()
514536 ->willReturn ('/my/path.crt ' );
515537
538+ $ acceptEnc = function_exists ('brotli_uncompress ' ) ? 'br, gzip ' : 'gzip ' ;
539+
540+ // compute curl http version hint like in production code
541+ $ curlVersion = \defined ('CURL_HTTP_VERSION_2TLS ' )
542+ ? \CURL_HTTP_VERSION_2TLS
543+ : (\defined ('CURL_HTTP_VERSION_2_0 ' ) ? \CURL_HTTP_VERSION_2_0 : \CURL_HTTP_VERSION_NONE );
544+
516545 $ this ->assertEquals ([
517546 'verify ' => '/my/path.crt ' ,
518547 'proxy ' => [
@@ -521,7 +550,7 @@ public function testSetDefaultOptionsWithProxy(): void {
521550 ],
522551 'headers ' => [
523552 'User-Agent ' => 'Nextcloud Server Crawler ' ,
524- 'Accept-Encoding ' => ' gzip ' ,
553+ 'Accept-Encoding ' => $ acceptEnc ,
525554 ],
526555 'timeout ' => 30 ,
527556 'nextcloud ' => [
@@ -535,6 +564,10 @@ public function testSetDefaultOptionsWithProxy(): void {
535564 ): void {
536565 },
537566 ],
567+ 'version ' => '2.0 ' ,
568+ 'curl ' => [
569+ \CURLOPT_HTTP_VERSION => $ curlVersion ,
570+ ],
538571 ], self ::invokePrivate ($ this ->client , 'buildRequestOptions ' , [[]]));
539572 }
540573
@@ -564,6 +597,13 @@ public function testSetDefaultOptionsWithProxyAndExclude(): void {
564597 ->with ()
565598 ->willReturn ('/my/path.crt ' );
566599
600+ $ acceptEnc = function_exists ('brotli_uncompress ' ) ? 'br, gzip ' : 'gzip ' ;
601+
602+ // compute curl http version hint like in production code
603+ $ curlVersion = \defined ('CURL_HTTP_VERSION_2TLS ' )
604+ ? \CURL_HTTP_VERSION_2TLS
605+ : (\defined ('CURL_HTTP_VERSION_2_0 ' ) ? \CURL_HTTP_VERSION_2_0 : \CURL_HTTP_VERSION_NONE );
606+
567607 $ this ->assertEquals ([
568608 'verify ' => '/my/path.crt ' ,
569609 'proxy ' => [
@@ -573,7 +613,7 @@ public function testSetDefaultOptionsWithProxyAndExclude(): void {
573613 ],
574614 'headers ' => [
575615 'User-Agent ' => 'Nextcloud Server Crawler ' ,
576- 'Accept-Encoding ' => ' gzip ' ,
616+ 'Accept-Encoding ' => $ acceptEnc ,
577617 ],
578618 'timeout ' => 30 ,
579619 'nextcloud ' => [
@@ -587,6 +627,10 @@ public function testSetDefaultOptionsWithProxyAndExclude(): void {
587627 ): void {
588628 },
589629 ],
630+ 'version ' => '2.0 ' ,
631+ 'curl ' => [
632+ \CURLOPT_HTTP_VERSION => $ curlVersion ,
633+ ],
590634 ], self ::invokePrivate ($ this ->client , 'buildRequestOptions ' , [[]]));
591635 }
592636}
0 commit comments