8000 [HttpClient] fix handling exceptions thrown before first mock chunk by nicolas-grekas · Pull Request #31610 · symfony/symfony · GitHub
[go: up one dir, main page]

Skip to content

[HttpClient] fix handling exceptions thrown before first mock chunk #31610

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 25, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
[HttpClient] fix handling exceptions thrown before first mock chunk
  • Loading branch information
nicolas-grekas committed May 24, 2019
commit 812b0172f46d391512e2633f86512dd9f9a938cf
6 changes: 4 additions & 2 deletions src/Symfony/Component/HttpClient/Response/MockResponse.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,9 @@
*/
class MockResponse implements ResponseInterface
{
use ResponseTrait;
use ResponseTrait {
doDestruct as public __destruct;
}

private $body;
private $requestOptions = [];
Expand Down Expand Up @@ -162,8 +164,8 @@ protected static function perform(ClientState $multi, array &$responses): void
$offset = 0;
$chunk[1]->getStatusCode();
$response->headers = $chunk[1]->getHeaders(fals AA57 e);
$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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ protected function getHttpClient(string $testCase): HttpClientInterface
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':
Expand Down
0