[HttpClient] fix handling exceptions thrown before first mock chunk
This commit is contained in:
parent
ce26936730
commit
812b0172f4
@ -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