@@ -462,5 +462,43 @@ private function rejectedConnectionMock()
462462 ->with ('www.example.com ' , 80 )
463463 ->will ($ this ->returnValue (new RejectedPromise (new \RuntimeException ())));
464464 }
465- }
466465
466+ /** @test */
467+ public function multivalueHeader ()
468+ {
469+ $ requestData = new RequestData ('GET ' , 'http://www.example.com ' );
470+ $ request = new Request ($ this ->connector , $ requestData );
471+
472+ $ this ->successfulConnectionMock ();
473+
474+ $ response = $ this ->response ;
475+
476+ $ response ->expects ($ this ->at (0 ))
477+ ->method ('on ' )
478+ ->with ('end ' , $ this ->anything ());
479+ $ response ->expects ($ this ->at (1 ))
480+ ->method ('on ' )
481+ ->with ('error ' , $ this ->anything ())
482+ ->will ($ this ->returnCallback (function ($ event , $ cb ) use (&$ errorCallback ) {
483+ $ errorCallback = $ cb ;
484+ }));
485+
486+ $ factory = $ this ->createCallableMock ();
487+ $ factory ->expects ($ this ->once ())
488+ ->method ('__invoke ' )
489+ ->with ('HTTP ' , '1.0 ' , '200 ' , 'OK ' , array ('Content-Type ' => 'text/plain ' , 'X-Xss-Protection ' => '1; mode=block ' , 'Cache-Control ' => 'public, must-revalidate, max-age=0 ' ))
490+ ->will ($ this ->returnValue ($ response ));
491+
492+ $ request ->setResponseFactory ($ factory );
493+ $ request ->end ();
494+
495+ $ request ->handleData ("HTTP/1.0 200 OK \r\n" );
496+ $ request ->handleData ("Content-Type: text/plain \r\n" );
497+ $ request ->handleData ("X-Xss-Protection:1; mode=block \r\n" );
498+ $ request ->handleData ("Cache-Control:public, must-revalidate, max-age=0 \r\n" );
499+ $ request ->handleData ("\r\nbody " );
500+
501+ $ this ->assertNotNull ($ errorCallback );
502+ call_user_func ($ errorCallback , new \Exception ('test ' ));
503+ }
504+ }
0 commit comments