@@ -321,6 +321,23 @@ public function testGet(): void {
321321 $ this ->assertEquals (418 , $ this ->client ->get ('http://localhost/ ' , [])->getStatusCode ());
322322 }
323323
324+ public function testGetStreamUsesHttp11 (): void {
325+ $ this ->setUpDefaultRequestOptions ();
326+
327+ $ options = array_merge ($ this ->defaultRequestOptions , [
328+ 'stream ' => true ,
329+ 'version ' => '1.1 ' ,
330+ 'curl ' => [
331+ \CURLOPT_HTTP_VERSION => \CURL_HTTP_VERSION_1_1 ,
332+ ],
333+ ]);
334+
335+ $ this ->guzzleClient ->method ('request ' )
336+ ->with ('get ' , 'http://localhost/ ' , $ options )
337+ ->willReturn (new Response (418 ));
338+ $ this ->assertEquals (418 , $ this ->client ->get ('http://localhost/ ' , ['stream ' => true ])->getStatusCode ());
339+ }
340+
324341 public function testGetWithOptions (): void {
325342 $ this ->setUpDefaultRequestOptions ();
326343
@@ -522,6 +539,57 @@ public function testSetDefaultOptionsWithNotInstalled(): void {
522539 ], self ::invokePrivate ($ this ->client , 'buildRequestOptions ' , [[]]));
523540 }
524541
542+ public function testSetDefaultOptionsWithStream (): void {
543+ $ this ->config
544+ ->expects ($ this ->exactly (3 ))
545+ ->method ('getSystemValueBool ' )
546+ ->willReturnMap ([
547+ ['installed ' , false , true ],
548+ ['allow_local_remote_servers ' , false , false ],
549+ ['http_client_add_user_agent_url ' , false , false ],
550+ ]);
551+ $ this ->config
552+ ->expects ($ this ->exactly (2 ))
553+ ->method ('getSystemValueString ' )
554+ ->willReturnMap ([
555+ ['proxy ' , '' , '' ],
556+ ['overwrite.cli.url ' , '' , '' ],
557+ ]);
558+ $ this ->certificateManager
559+ ->expects ($ this ->once ())
560+ ->method ('getAbsoluteBundlePath ' )
561+ ->with ()
562+ ->willReturn ('/my/path.crt ' );
563+
564+ $ this ->serverVersion ->method ('getVersionString ' )
565+ ->willReturn ('123.45.6 ' );
566+
567+ $ this ->assertEquals ([
568+ 'verify ' => '/my/path.crt ' ,
569+ 'headers ' => [
570+ 'User-Agent ' => 'Nextcloud-Server-Crawler/123.45.6 ' ,
571+ 'Accept-Encoding ' => 'gzip ' ,
572+ ],
573+ 'timeout ' => 30 ,
574+ 'nextcloud ' => [
575+ 'allow_local_address ' => false ,
576+ ],
577+ 'allow_redirects ' => [
578+ 'on_redirect ' => function (
579+ \Psr \Http \Message \RequestInterface $ request ,
580+ \Psr \Http \Message \ResponseInterface $ response ,
581+ \Psr \Http \Message \UriInterface $ uri ,
582+ ): void {
583+ },
584+ ],
585+ 'stream ' => true ,
586+ 'version ' => '1.1 ' ,
587+ 'curl ' => [
588+ \CURLOPT_HTTP_VERSION => \CURL_HTTP_VERSION_1_1 ,
589+ ],
590+ ], self ::invokePrivate ($ this ->client , 'buildRequestOptions ' , [['stream ' => true ]]));
591+ }
592+
525593 public function testSetDefaultOptionsWithProxy (): void {
526594 $ this ->config
527595 ->expects ($ this ->exactly (3 ))
0 commit comments