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] Fix exception triggered with AsyncResponse#38378

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
nicolas-grekas merged 1 commit intosymfony:masterfromjderusse:fix-async
Oct 2, 2020

Conversation

@jderusse
Copy link
Member

@jderussejderusse commentedOct 2, 2020
edited
Loading

QA
Branch?master
Bug fix?yes
New feature?no
Deprecations?no
Tickets#38289 (comment)
LicenseMIT
Doc PR/

When a request is replayed with the AsyncResponse and the 2nd request failed, users get an exception even when they pass$throw=false.

In fact, there are 2 exceptions:

  1. Cannot get the content of the response twice: buffering is disabled.

if (null ===$this->content) {
$content =null;
foreach (self::stream([$this])as$chunk) {
if (!$chunk->isLast()) {
$content .=$chunk->getContent();
}
}
if (null !==$content) {
return$content;
}
if ('HEAD' ===$this->getInfo('http_method') ||\in_array($this->getInfo('http_code'), [204,304],true)) {
return'';
}
thrownewTransportException('Cannot get the content of the response twice: buffering is disabled.');

Because CommonResponseTrait::$content is null andself::stream yield only the LastChunk. The content is stays null

  1. HTTP/2 429 returned for "https://httpbin.org/status/429"

if (!$r->passthru) {
if (null !==$chunk->getError() ||$chunk->isLast()) {
unset($asyncMap[$response]);
}elseif (null !==$r->content &&'' !== ($content =$chunk->getContent()) &&\strlen($content) !==fwrite($r->content,$content)) {
$chunk =newErrorChunk($r->offset,newTransportException(sprintf('Failed writing %d bytes to the response buffer.',\strlen($content))));
$r->info['error'] =$chunk->getError();
$r->response->cancel();
}
yield$r =>$chunk;
continue;
}
if (null ===$chunk->getError() &&$chunk->isFirst()) {
// Ensure no exception is thrown on destruct for the wrapped response
$r->response->getStatusCode();
}

Because on the second request passthru is null, it didn't disable the the exception thrown on destruct for the wrapped response.
This

bohanwood reacted with thumbs up emoji
@nicolas-grekasnicolas-grekas changed the titleFix exception triggered with AsyncResponse[HttpClient] Fix exception triggered with AsyncResponseOct 2, 2020
@nicolas-grekas
Copy link
Member

Thank you@jderusse.

@nicolas-grekasnicolas-grekas merged commit1f7b8fd intosymfony:masterOct 2, 2020
@nicolas-grekasnicolas-grekas modified the milestones:next,5.2Oct 5, 2020
@jderussejderusse deleted the fix-async branchOctober 15, 2020 10:01
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

@nicolas-grekasnicolas-grekasnicolas-grekas left review comments

Assignees

No one assigned

Projects

None yet

Milestone

5.2

Development

Successfully merging this pull request may close these issues.

3 participants

@jderusse@nicolas-grekas@carsonbot

[8]ページ先頭

©2009-2025 Movatter.jp