bug #31610 [HttpClient] fix handling exceptions thrown before first mock chunk (nicolas-grekas)
This PR was merged into the 4.3 branch.
Discussion
----------
[HttpClient] fix handling exceptions thrown before first mock chunk
| Q | A
| ------------- | ---
| Branch? | 4.3
| Bug fix? | yes
| New feature? | no
| BC breaks? | no
| Deprecations? | no
| Tests pass? | yes
| Fixed tickets | -
| License | MIT
| Doc PR | -
Discovered while fixing a 60s timeout on a test case, which this fixes too.
Commits
-------
812b0172f4
[HttpClient] fix handling exceptions thrown before first mock chunk
This commit is contained in:
commit
6aacfea491
@ -25,7 +25,9 @@ use Symfony\Contracts\HttpClient\ResponseInterface;
|
||||
*/
|
||||
class MockResponse implements ResponseInterface
|
||||
{
|
||||
use ResponseTrait;
|
||||
use ResponseTrait {
|
||||
doDestruct as public __destruct;
|
||||
}
|
||||
|
||||
private $body;
|
||||
private $requestOptions = [];
|
||||
@ -162,8 +164,8 @@ class MockResponse implements ResponseInterface
|
||||
$offset = 0;
|
||||
$chunk[1]->getStatusCode();
|
||||
$response->headers = $chunk[1]->getHeaders(false);
|
||||
$multi->handlesActivity[$id][] = new FirstChunk();
|
||||
self::readResponse($response, $chunk[0], $chunk[1], $offset);
|
||||
$multi->handlesActivity[$id][] = new FirstChunk();
|
||||
} catch (\Throwable $e) {
|
||||
$multi->handlesActivity[$id][] = null;
|
||||
$multi->handlesActivity[$id][] = $e;
|
||||
|
@ -115,7 +115,7 @@ class MockHttpClientTest extends HttpClientTestCase
|
||||
case 'testResolve':
|
||||
$responses[] = new MockResponse($body, ['response_headers' => $headers]);
|
||||
$responses[] = new MockResponse($body, ['response_headers' => $headers]);
|
||||
$responses[] = $client->request('GET', 'http://symfony.com:8057/');
|
||||
$responses[] = new MockResponse((function () { throw new \Exception('Fake connection timeout'); yield ''; })(), ['response_headers' => $headers]);
|
||||
break;
|
||||
|
||||
case 'testTimeoutOnStream':
|
||||
|
Reference in New Issue
Block a user