minor #36771 [HttpClient] test that timeout is not fatal (nicolas-grekas)
This PR was merged into the 4.4 branch.
Discussion
----------
[HttpClient] test that timeout is not fatal
| Q | A
| ------------- | ---
| Branch? | 4.4
| Bug fix? | no
| New feature? | no
| Deprecations? | no
| Tickets | -
| License | MIT
| Doc PR | -
Commits
-------
36ccf4c65b
[HttpClient] test that timeout is not fatal
This commit is contained in:
commit
99d5818489
@ -12,6 +12,7 @@
|
||||
namespace Symfony\Component\HttpClient\Tests;
|
||||
|
||||
use Symfony\Component\HttpClient\Exception\ClientException;
|
||||
use Symfony\Component\HttpClient\Exception\TransportException;
|
||||
use Symfony\Contracts\HttpClient\Test\HttpClientTestCase as BaseHttpClientTestCase;
|
||||
|
||||
abstract class HttpClientTestCase extends BaseHttpClientTestCase
|
||||
@ -91,4 +92,21 @@ abstract class HttpClientTestCase extends BaseHttpClientTestCase
|
||||
$this->assertSame('', fread($stream, 8192));
|
||||
$this->assertTrue(feof($stream));
|
||||
}
|
||||
|
||||
public function testTimeoutIsNotAFatalError()
|
||||
{
|
||||
$client = $this->getHttpClient(__FUNCTION__);
|
||||
$response = $client->request('GET', 'http://localhost:8057/timeout-body', [
|
||||
'timeout' => 0.1,
|
||||
]);
|
||||
|
||||
try {
|
||||
$response->getContent();
|
||||
$this->fail(TransportException::class.' expected');
|
||||
} catch (TransportException $e) {
|
||||
}
|
||||
|
||||
usleep(400000);
|
||||
$this->assertSame('<1><2>', $response->getContent());
|
||||
}
|
||||
}
|
||||
|
@ -132,6 +132,7 @@ class MockHttpClientTest extends HttpClientTestCase
|
||||
|
||||
case 'testTimeoutOnStream':
|
||||
case 'testUncheckedTimeoutThrows':
|
||||
case 'testTimeoutIsNotAFatalError':
|
||||
$body = ['<1>', '', '<2>'];
|
||||
$responses[] = new MockResponse($body, ['response_headers' => $headers]);
|
||||
break;
|
||||
|
Reference in New Issue
Block a user