File tree 2 files changed +19
-0
lines changed
src/Symfony/Component/HttpClient/Tests 2 files changed +19
-0
lines changed Original file line number Diff line number Diff line change 12
12
namespace Symfony \Component \HttpClient \Tests ;
13
13
14
14
use Symfony \Component \HttpClient \Exception \ClientException ;
15
+ use Symfony \Component \HttpClient \Exception \TransportException ;
15
16
use Symfony \Contracts \HttpClient \Test \HttpClientTestCase as BaseHttpClientTestCase ;
16
17
17
18
abstract class HttpClientTestCase extends BaseHttpClientTestCase
@@ -91,4 +92,21 @@ public function testNonBlockingStream()
91
92
$ this ->assertSame ('' , fread ($ stream , 8192 ));
92
93
$ this ->assertTrue (feof ($ stream ));
93
94
}
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
+ }
94
112
}
Original file line number Diff line number Diff line change @@ -132,6 +132,7 @@ protected function getHttpClient(string $testCase): HttpClientInterface
132
132
133
133
case 'testTimeoutOnStream ' :
134
134
case 'testUncheckedTimeoutThrows ' :
135
+ case 'testTimeoutIsNotAFatalError ' :
135
136
$ body = ['<1> ' , '' , '<2> ' ];
136
137
$ responses [] = new MockResponse ($ body , ['response_headers ' => $ headers ]);
137
138
break ;
You can’t perform that action at this time.
0 commit comments