Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

[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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
fabpot merged 1 commit intosymfony:5.xfromjderusse:hc-stopwatch
Oct 23, 2020

Conversation

@jderusse
Copy link
Member

@jderussejderusse commentedOct 23, 2020
edited
Loading

QA
Branch?5.x
Bug fix?no
New feature?yes
Deprecations?no
Tickets-
LicenseMIT
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

tyx reacted with heart emojiOskarStark and Koc reacted with rocket emoji
Copy link
Member

@NyholmNyholm 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-grekasnicolas-grekasOct 23, 2020
edited
Loading

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
MemberAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Good catch.
I addedlap on timeout and chunk (same forgetStatus andgetHeader) 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 ($responsesas$response) {$response->getContent();        }

@jderussejderusseforce-pushed thehc-stopwatch branch 3 times, most recently frombcab52a to5759497CompareOctober 23, 2020 09:00
@jderussejderusseforce-pushed thehc-stopwatch branch 2 times, most recently froma7f9109 toff928bcCompareOctober 23, 2020 10:03
@nicolas-grekasnicolas-grekas modified the milestones:5.2,5.xOct 23, 2020
@fabpot
Copy link
Member

Thank you@jderusse.

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

Reviewers

@stofstofstof left review comments

@fabpotfabpotfabpot approved these changes

@nicolas-grekasnicolas-grekasnicolas-grekas approved these changes

@NyholmNyholmNyholm approved these changes

Assignees

No one assigned

Projects

None yet

Milestone

5.4

Development

Successfully merging this pull request may close these issues.

6 participants

@jderusse@fabpot@nicolas-grekas@stof@Nyholm@carsonbot

[8]ページ先頭

©2009-2025 Movatter.jp