Skip to content

fix(client): early server response shouldn't propagate NO_ERROR#3275

Merged
seanmonstar merged 2 commits into
hyperium:masterfrom
DDtKey:fix-rst-stream-error-for-early-response-h2
Jul 26, 2023
Merged

fix(client): early server response shouldn't propagate NO_ERROR#3275
seanmonstar merged 2 commits into
hyperium:masterfrom
DDtKey:fix-rst-stream-error-for-early-response-h2

Conversation

@DDtKey

@DDtKey DDtKey commented Jul 23, 2023

Copy link
Copy Markdown
Contributor

Closes #2872

Added test is failing against the current version (before this fix)

Backport for 0.14.x: #3274

Closes hyperium#2872

Added test is failing against version without these changes.
Comment thread src/body/incoming.rs
Some(Err(e)) => {
return match e.reason() {
// These reasons should cause stop of body reading, but don't fail it.
// The same logic as for `Read for H2Upgraded` is applied here.

@DDtKey DDtKey Jul 23, 2023

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I'm referring to this line here:

Some(Reason::NO_ERROR) | Some(Reason::CANCEL) => Ok(()),

And it makes sense in terms of protocol behavior for the reasons.

Both of them call the same operation (self.recv_stream.poll_data(cx)) and seems that logic should be the same. But we can make it more specific.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Btw, an additional example from another lang & lib where it was also solved by avoiding error if response has been read: square/okhttp#6295

@DDtKey DDtKey changed the title fix: early respond from server shouldn't propagate reset error fix: early server response shouldn't propagate reset error Jul 23, 2023
@DDtKey DDtKey changed the title fix: early server response shouldn't propagate reset error fix: early server response shouldn't propagate NO_ERROR Jul 23, 2023
@DDtKey DDtKey changed the title fix: early server response shouldn't propagate NO_ERROR fix(client): early server response shouldn't propagate NO_ERROR Jul 23, 2023
@seanmonstar seanmonstar requested a review from nox July 24, 2023 18:46

@nox nox left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Seems good to me given we already do something similar for streams upgraded from HTTP/2.

@seanmonstar seanmonstar merged commit 194e6f9 into hyperium:master Jul 26, 2023
0xE282B0 pushed a commit to 0xE282B0/hyper that referenced this pull request Jan 16, 2024
seanmonstar pushed a commit that referenced this pull request Apr 22, 2026
…y response (#3998)

This is the trailers variant of the fix for reading the body in #3275, so that it is possible to both attempt to read the body and the trailers when the server has sent a `RST_STREAM` with `NO_ERROR` after its response to indicate that the client should stop attempting to send it the body.

I have added a trailers-only variant of `http2_responds_before_consuming_request_body` that fails without the fix, and also updated `http2_responds_before_consuming_request_body` to verify that it can check whether there are any trailers.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Client: handle RST_STREAM with NO_ERROR set for the reason

3 participants