File tree Expand file tree Collapse file tree 2 files changed +19
-0
lines changed Expand file tree Collapse file tree 2 files changed +19
-0
lines changed Original file line number Diff line number Diff line change 1212namespace Symfony \Component \HttpClient \Tests ;
1313
1414use Symfony \Component \HttpClient \Exception \ClientException ;
15+ use Symfony \Component \HttpClient \Exception \TransportException ;
1516use Symfony \Contracts \HttpClient \Test \HttpClientTestCase as BaseHttpClientTestCase ;
1617
1718abstract class HttpClientTestCase extends BaseHttpClientTestCase
@@ -91,4 +92,21 @@ public function testNonBlockingStream()
9192 $ this ->assertSame ('' , fread ($ stream , 8192 ));
9293 $ this ->assertTrue (feof ($ stream ));
9394 }
95+
96+ public function testTimeoutIsNotAFatalError ()
97+ {
98+ $ client = $ this ->getHttpClient (__FUNCTION__ );
99+ $ response = $ client ->request ('GET ' , 'http://localhost:8057/timeout-body ' , [
100+ 'timeout ' => 0.1 ,
101+ ]);
102+
103+ try {
104+ $ response ->getContent ();
105+ $ this ->fail (TransportException::class.' expected ' );
106+ } catch (TransportException $ e ) {
107+ }
108+
109+ usleep (400000 );
110+ $ this ->assertSame ('<1><2> ' , $ response ->getContent ());
111+ }
94112}
Original file line number Diff line number Diff line change @@ -132,6 +132,7 @@ protected function getHttpClient(string $testCase): HttpClientInterface
132132
133133 case 'testTimeoutOnStream ' :
134134 case 'testUncheckedTimeoutThrows ' :
135+ case 'testTimeoutIsNotAFatalError ' :
135136 $ body = ['<1> ' , '' , '<2> ' ];
136137 $ responses [] = new MockResponse ($ body , ['response_headers ' => $ headers ]);
137138 break ;
You can’t perform that action at this time.
0 commit comments