Repository navigation
http-netty: stop sending the request body after an error response with Connection: close - #3734
Open
idelpivnitskiy wants to merge 1 commit into
Open
idelpivnitskiy wants to merge 1 commit into
idelpivnitskiy wants to merge 1 commit into
Conversation
…h Connection: close #### Motivation [RFC 9112 section 9.5](https://www.rfc-editor.org/rfc/rfc9112#section-9.5): a client that sees a response indicating the server doesn't want the request body and is closing the connection SHOULD stop sending the body. The HTTP/1.1 client kept uploading the whole body, e.g. after a late rejection of `Expect: 100-continue` or an early `413` to a plain upload. With writes still queued, the closed connection could also fail the response. #### Modifications - On a final non-2xx response that closes the connection, `HttpResponseDecoder` stops a request payload body that is still being sent. The encoder marks the request complete, so the connection closes after the response. - `WriteStreamSubscriber.terminateSource()` can stop a source that is already writing. The write completes without waiting for in-flight writes, so their failure on close doesn't fail the response. A request that wrote nothing yet is left alone, so it still fails as retryable, and writes already aborted (pipelined requests) or failed by the source keep their failure. - Responses without `Connection: close` don't stop the body: the server may keep reading it. #### Result The client stops uploading once the server rejects the request and closes the connection, and still delivers the response. Less unread request data on the server also makes a TCP RST less likely when the server closes the connection non-gracefully after a non-2xx response, which could otherwise cut the response short.
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Motivation
RFC 9112 section 9.5: a client that sees a response indicating the server doesn't want the request body and is closing the connection SHOULD stop sending the body.
The HTTP/1.1 client kept uploading the whole body, e.g. after a late rejection of
Expect: 100-continueor anearly
413to a plain upload. With writes still queued, the closed connection could also fail the response.Modifications
HttpResponseDecoderstops a request payload body thatis still being sent. The encoder marks the request complete, so the connection closes after the response.
WriteStreamSubscriber.terminateSource()can stop a source that is already writing. The write completes withoutwaiting for in-flight writes, so their failure on close doesn't fail the response. A request that wrote nothing
yet is left alone, so it still fails as retryable, and writes already aborted (pipelined requests) or failed by
the source keep their failure.
Connection: closedon't stop the body: the server may keep reading it.Result
The client stops uploading once the server rejects the request and closes the connection, and still delivers the
response. Less unread request data on the server also makes a TCP RST less likely when the server closes the
connection non-gracefully after a non-2xx response, which could otherwise cut the response short.