-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
[HttpClient] Add a Stopwatch on TraceableHttpClient #38688
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
Conversation
a622a5a
to
5ab338b
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is an excellent idea. Thank you
@@ -132,6 +170,9 @@ public static function stream(HttpClientInterface $client, iterable $responses, | |||
} | |||
|
|||
foreach ($client->stream($wrappedResponses, $timeout) as $r => $chunk) { | |||
if ($traceableMap[$r]->event && $traceableMap[$r]->event->isStarted() && $chunk->isLast()) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
calling isLast() without checking for getError will throw when an error happens (same for timeouts)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good catch.
I added lap
on timeout and chunk (same for getStatus
and getHeader
) To show a "tick" when content is partially received.
$response1 = $client->request('GET', 'https://httpstat.us/200');
$response1->getContent(false);
$response2 = $client->request('GET', 'https://httpstat.us/404');
$response2->getContent(false);
$responses[] = $client->request('GET', 'https://httpstat.us/200?sleep=3000');
$responses[] = $client->request('GET', 'https://httpstat.us/200?sleep=500');
try {
foreach ($client->stream($responses, 1) as $chunk) {}
} catch (\Exception $e)
{}
sleep(1);
foreach ($responses as $response) {
$response->getContent();
}
bcab52a
to
5759497
Compare
src/Symfony/Component/HttpClient/Response/TraceableResponse.php
Outdated
Show resolved
Hide resolved
src/Symfony/Component/HttpClient/Response/TraceableResponse.php
Outdated
Show resolved
Hide resolved
a7f9109
to
ff928bc
Compare
ff928bc
to
e6f6b4c
Compare
Thank you @jderusse. |
I used this code to generate the screenshot below.