@@ -765,6 +765,64 @@ public function testSendContinuedWithManyHeaders()
765765 $ this ->assertSame (200 , $ response ->getStatusCode ());
766766 }
767767
768+ /**
769+ * See: https://github.com/codeigniter4/CodeIgniter4/issues/7394
770+ */
771+ public function testResponseHeadersWithMultipleRequests ()
772+ {
773+ $ request = $ this ->getRequest ([
774+ 'base_uri ' => 'http://www.foo.com/api/v1/ ' ,
775+ ]);
776+
777+ $ output = "HTTP/2.0 200 OK
778+ Server: ddos-guard
779+ Expires: Thu, 19 Nov 1981 08:52:00 GMT
780+ Cache-Control: no-store, no-cache, must-revalidate
781+ Pragma: no-cache
782+ Content-Type: application/xml; charset=utf-8
783+ Transfer-Encoding: chunked \x0d\x0a\x0d\x0a<title>Hello</title> " ;
784+ $ request ->setOutput ($ output );
785+
786+ $ response = $ request ->get ('answer ' );
787+
788+ $ this ->assertSame ('<title>Hello</title> ' , $ response ->getBody ());
789+
790+ $ responseHeaderKeys = [
791+ 'Cache-Control ' ,
792+ 'Content-Type ' ,
793+ 'Server ' ,
794+ 'Expires ' ,
795+ 'Pragma ' ,
796+ 'Transfer-Encoding ' ,
797+ ];
798+ $ this ->assertSame ($ responseHeaderKeys , array_keys ($ response ->headers ()));
799+
800+ $ this ->assertSame (200 , $ response ->getStatusCode ());
801+
802+ $ output = "HTTP/2.0 200 OK
803+ Server: ddos-guard
804+ Expires: Thu, 19 Nov 1982 08:52:00 GMT
805+ Content-Type: application/xml; charset=utf-8
806+ Transfer-Encoding: chunked \x0d\x0a\x0d\x0a<title>Hello</title> " ;
807+ $ request ->setOutput ($ output );
808+
809+ $ response = $ request ->get ('answer ' );
810+
811+ $ this ->assertSame ('<title>Hello</title> ' , $ response ->getBody ());
812+
813+ $ responseHeaderKeys = [
814+ 'Cache-Control ' ,
815+ 'Content-Type ' ,
816+ 'Server ' ,
817+ 'Expires ' ,
818+ 'Pragma ' ,
819+ 'Transfer-Encoding ' ,
820+ ];
821+ $ this ->assertSame ($ responseHeaderKeys , array_keys ($ response ->headers ()));
822+
823+ $ this ->assertSame (200 , $ response ->getStatusCode ());
824+ }
825+
768826 public function testSplitResponse ()
769827 {
770828 $ request = $ this ->getRequest ([
0 commit comments