2929 */
3030final class CURLRequestDoNotShareOptionsTest extends CIUnitTestCase
3131{
32- private CURLRequest $ request ;
32+ private MockCURLRequest $ request ;
3333
3434 protected function setUp (): void
3535 {
@@ -39,7 +39,7 @@ protected function setUp(): void
3939 $ this ->request = $ this ->getRequest ();
4040 }
4141
42- protected function getRequest (array $ options = [])
42+ protected function getRequest (array $ options = []): MockCURLRequest
4343 {
4444 $ uri = isset ($ options ['base_uri ' ]) ? new URI ($ options ['base_uri ' ]) : new URI ();
4545 $ app = new App ();
@@ -404,20 +404,20 @@ public function testAuthBasicOptionExplicit(): void
404404 public function testAuthDigestOption (): void
405405 {
406406 $ output = "HTTP/1.1 401 Unauthorized
407- Server: ddos-guard
408- Set-Cookie: __ddg1=z177j4mLtqzC07v0zviU; Domain=.site.ru; HttpOnly; Path=/; Expires=Wed, 07-Jul-2021 15:13:14 GMT
409- WWW-Authenticate: Digest \x0d\x0a\x0d\x0aHTTP/1.1 200 OK
410- Server: ddos-guard
411- Connection: keep-alive
412- Keep-Alive: timeout=60
413- Set-Cookie: __ddg1=z177j4mLtqzC07v0zviU; Domain=.site.ru; HttpOnly; Path=/; Expires=Wed, 07-Jul-2021 15:13:14 GMT
414- Date: Tue, 07 Jul 2020 15:13:14 GMT
415- Expires: Thu, 19 Nov 1981 08:52:00 GMT
416- Cache-Control: no-store, no-cache, must-revalidate
417- Pragma: no-cache
418- Set-Cookie: PHPSESSID=80pd3hlg38mvjnelpvokp9lad0; path=/
419- Content-Type: application/xml; charset=utf-8
420- Transfer-Encoding: chunked \x0d\x0a\x0d\x0a<title>Update success! config</title> " ;
407+ Server: ddos-guard
408+ Set-Cookie: __ddg1=z177j4mLtqzC07v0zviU; Domain=.site.ru; HttpOnly; Path=/; Expires=Wed, 07-Jul-2021 15:13:14 GMT
409+ WWW-Authenticate: Digest \x0d\x0a\x0d\x0aHTTP/1.1 200 OK
410+ Server: ddos-guard
411+ Connection: keep-alive
412+ Keep-Alive: timeout=60
413+ Set-Cookie: __ddg1=z177j4mLtqzC07v0zviU; Domain=.site.ru; HttpOnly; Path=/; Expires=Wed, 07-Jul-2021 15:13:14 GMT
414+ Date: Tue, 07 Jul 2020 15:13:14 GMT
415+ Expires: Thu, 19 Nov 1981 08:52:00 GMT
416+ Cache-Control: no-store, no-cache, must-revalidate
417+ Pragma: no-cache
418+ Set-Cookie: PHPSESSID=80pd3hlg38mvjnelpvokp9lad0; path=/
419+ Content-Type: application/xml; charset=utf-8
420+ Transfer-Encoding: chunked \x0d\x0a\x0d\x0a<title>Update success! config</title> " ;
421421
422422 $ this ->request ->setOutput ($ output );
423423
@@ -457,20 +457,20 @@ public function testSetAuthBasic(): void
457457 public function testSetAuthDigest (): void
458458 {
459459 $ output = "HTTP/1.1 401 Unauthorized
460- Server: ddos-guard
461- Set-Cookie: __ddg1=z177j4mLtqzC07v0zviU; Domain=.site.ru; HttpOnly; Path=/; Expires=Wed, 07-Jul-2021 15:13:14 GMT
462- WWW-Authenticate: Digest \x0d\x0a\x0d\x0aHTTP/1.1 200 OK
463- Server: ddos-guard
464- Connection: keep-alive
465- Keep-Alive: timeout=60
466- Set-Cookie: __ddg1=z177j4mLtqzC07v0zviU; Domain=.site.ru; HttpOnly; Path=/; Expires=Wed, 07-Jul-2021 15:13:14 GMT
467- Date: Tue, 07 Jul 2020 15:13:14 GMT
468- Expires: Thu, 19 Nov 1981 08:52:00 GMT
469- Cache-Control: no-store, no-cache, must-revalidate
470- Pragma: no-cache
471- Set-Cookie: PHPSESSID=80pd3hlg38mvjnelpvokp9lad0; path=/
472- Content-Type: application/xml; charset=utf-8
473- Transfer-Encoding: chunked \x0d\x0a\x0d\x0a<title>Update success! config</title> " ;
460+ Server: ddos-guard
461+ Set-Cookie: __ddg1=z177j4mLtqzC07v0zviU; Domain=.site.ru; HttpOnly; Path=/; Expires=Wed, 07-Jul-2021 15:13:14 GMT
462+ WWW-Authenticate: Digest \x0d\x0a\x0d\x0aHTTP/1.1 200 OK
463+ Server: ddos-guard
464+ Connection: keep-alive
465+ Keep-Alive: timeout=60
466+ Set-Cookie: __ddg1=z177j4mLtqzC07v0zviU; Domain=.site.ru; HttpOnly; Path=/; Expires=Wed, 07-Jul-2021 15:13:14 GMT
467+ Date: Tue, 07 Jul 2020 15:13:14 GMT
468+ Expires: Thu, 19 Nov 1981 08:52:00 GMT
469+ Cache-Control: no-store, no-cache, must-revalidate
470+ Pragma: no-cache
471+ Set-Cookie: PHPSESSID=80pd3hlg38mvjnelpvokp9lad0; path=/
472+ Content-Type: application/xml; charset=utf-8
473+ Transfer-Encoding: chunked \x0d\x0a\x0d\x0a<title>Update success! config</title> " ;
474474
475475 $ this ->request ->setOutput ($ output );
476476
@@ -784,14 +784,14 @@ public function testSendContinuedWithManyHeaders(): void
784784
785785 $ responseHeaderKeys = [
786786 'Cache-Control ' ,
787- 'Content-Type ' ,
788787 'Server ' ,
789788 'Connection ' ,
790789 'Keep-Alive ' ,
791790 'Set-Cookie ' ,
792791 'Date ' ,
793792 'Expires ' ,
794793 'Pragma ' ,
794+ 'Content-Type ' ,
795795 'Transfer-Encoding ' ,
796796 ];
797797 $ this ->assertSame ($ responseHeaderKeys , array_keys ($ response ->headers ()));
@@ -823,10 +823,10 @@ public function testResponseHeadersWithMultipleRequests(): void
823823
824824 $ responseHeaderKeys = [
825825 'Cache-Control ' ,
826- 'Content-Type ' ,
827826 'Server ' ,
828827 'Expires ' ,
829828 'Pragma ' ,
829+ 'Content-Type ' ,
830830 'Transfer-Encoding ' ,
831831 ];
832832 $ this ->assertSame ($ responseHeaderKeys , array_keys ($ response ->headers ()));
@@ -846,8 +846,8 @@ public function testResponseHeadersWithMultipleRequests(): void
846846
847847 $ responseHeaderKeys = [
848848 'Cache-Control ' ,
849- 'Content-Type ' ,
850849 'Expires ' ,
850+ 'Content-Type ' ,
851851 'Transfer-Encoding ' ,
852852 ];
853853 $ this ->assertSame ($ responseHeaderKeys , array_keys ($ response ->headers ()));
@@ -1141,4 +1141,21 @@ public function testUserAgentOption(): void
11411141 $ this ->assertArrayHasKey (CURLOPT_USERAGENT , $ options );
11421142 $ this ->assertSame ($ agent , $ options [CURLOPT_USERAGENT ]);
11431143 }
1144+
1145+ public function testGetHeaderLineContentType (): void
1146+ {
1147+ $ output = 'HTTP/2 200
1148+ date: Thu, 11 Apr 2024 07:26:00 GMT
1149+ content-type: text/html; charset=UTF-8
1150+ cache-control: no-store, max-age=0, no-cache
1151+ server: cloudflare
1152+ content-encoding: br
1153+ alt-svc: h3=":443"; ma=86400 ' . "\x0d\x0a\x0d\x0aResponse Body " ;
1154+
1155+ $ this ->request ->setOutput ($ output );
1156+
1157+ $ response = $ this ->request ->request ('get ' , 'http://example.com ' );
1158+
1159+ $ this ->assertSame ('text/html; charset=UTF-8 ' , $ response ->getHeaderLine ('Content-Type ' ));
1160+ }
11441161}
0 commit comments