Skip to content

Conversation

@jderusse
Copy link
Member

@jderusse jderusse commented Oct 23, 2020

Q A
Branch? 5.x
Bug fix? no
New feature? yes
Deprecations? no
Tickets -
License MIT
Doc PR -

I used this code to generate the screenshot below.

$response = $client->request('GET', 'https://httpstat.us/200');
$response->getContent();

$responses[] = $client->request('GET', 'https://httpstat.us/200?sleep=300');
$responses[] = $client->request('GET', 'https://httpstat.us/200?sleep=100');
foreach ($client->stream($responses) as $chunk) {
}

Screenshot from 2020-10-23 02-04-43

Copy link
Member

@Nyholm Nyholm left a 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

}

foreach ($client->stream($wrappedResponses, $timeout) as $r => $chunk) {
if ($traceableMap[$r]->event && $traceableMap[$r]->event->isStarted() && $chunk->isLast()) {
Copy link
Member

@nicolas-grekas nicolas-grekas Oct 23, 2020

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)

Copy link
Member Author

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.

Screenshot from 2020-10-23 10-52-45

        $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();
        }

@jderusse jderusse force-pushed the hc-stopwatch branch 3 times, most recently from bcab52a to 5759497 Compare October 23, 2020 09:00
@jderusse jderusse force-pushed the hc-stopwatch branch 2 times, most recently from a7f9109 to ff928bc Compare October 23, 2020 10:03
@nicolas-grekas nicolas-grekas modified the milestones: 5.2, 5.x Oct 23, 2020
@fabpot
Copy link
Member

fabpot commented Oct 23, 2020

Thank you @jderusse.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants