@@ -782,6 +782,62 @@ public function testSendContinuedWithManyHeaders()
782782 $ this ->assertSame (200 , $ response ->getStatusCode ());
783783 }
784784
785+ /**
786+ * See: https://github.com/codeigniter4/CodeIgniter4/issues/7394
787+ */
788+ public function testResponseHeadersWithMultipleRequests ()
789+ {
790+ $ request = $ this ->getRequest ([
791+ 'base_uri ' => 'http://www.foo.com/api/v1/ ' ,
792+ ]);
793+
794+ $ output = "HTTP/2.0 200 OK
795+ Server: ddos-guard
796+ Expires: Thu, 19 Nov 1981 08:52:00 GMT
797+ Cache-Control: no-store, no-cache, must-revalidate
798+ Pragma: no-cache
799+ Content-Type: application/xml; charset=utf-8
800+ Transfer-Encoding: chunked \x0d\x0a\x0d\x0a<title>Hello1</title> " ;
801+ $ request ->setOutput ($ output );
802+
803+ $ response = $ request ->get ('answer1 ' );
804+
805+ $ this ->assertSame ('<title>Hello1</title> ' , $ response ->getBody ());
806+
807+ $ responseHeaderKeys = [
808+ 'Cache-Control ' ,
809+ 'Content-Type ' ,
810+ 'Server ' ,
811+ 'Expires ' ,
812+ 'Pragma ' ,
813+ 'Transfer-Encoding ' ,
814+ ];
815+ $ this ->assertSame ($ responseHeaderKeys , array_keys ($ response ->headers ()));
816+
817+ $ this ->assertSame (200 , $ response ->getStatusCode ());
818+
819+ $ output = "HTTP/2.0 200 OK
820+ Expires: Thu, 19 Nov 1982 08:52:00 GMT
821+ Cache-Control: no-store, no-cache, must-revalidate
822+ Content-Type: application/xml; charset=utf-8
823+ Transfer-Encoding: chunked \x0d\x0a\x0d\x0a<title>Hello2</title> " ;
824+ $ request ->setOutput ($ output );
825+
826+ $ response = $ request ->get ('answer2 ' );
827+
828+ $ this ->assertSame ('<title>Hello2</title> ' , $ response ->getBody ());
829+
830+ $ responseHeaderKeys = [
831+ 'Cache-Control ' ,
832+ 'Content-Type ' ,
833+ 'Expires ' ,
834+ 'Transfer-Encoding ' ,
835+ ];
836+ $ this ->assertSame ($ responseHeaderKeys , array_keys ($ response ->headers ()));
837+
838+ $ this ->assertSame (200 , $ response ->getStatusCode ());
839+ }
840+
785841 public function testSplitResponse ()
786842 {
787843 $ request = $ this ->getRequest ([
0 commit comments