Repository navigation
Reset an HTTP/2 stream rather than end it short of the content-length - #1248
Open
arturobernalg wants to merge 1 commit into
Open
arturobernalg wants to merge 1 commit into
arturobernalg wants to merge 1 commit into
Conversation
RFC 9113, section 8.1.1 states that a response is malformed if the value of the content-length header field is not the sum of the DATA frame payloads. An application that ended its response having written fewer bytes than the content length it had set had the stream ended normally, so the client received a truncated response that looked complete. Reset the stream with PROTOCOL_ERROR in that case so that the client can tell the response is incomplete. Responses that have no body, such as those to HEAD requests, are not affected.
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.
RFC 9113, section 8.1.1 states that a response is malformed if the value of the content-length header field is not the sum of the DATA frame payloads.
An application that ends its response having written fewer bytes than the content length it set currently has the stream ended normally, so the client receives a truncated response that looks complete. With HTTP/1.1 the client keeps waiting for the missing bytes instead.
This resets the stream with PROTOCOL_ERROR in that case. Responses that have no body, such as those to HEAD requests, are not affected.
Checked against a running Tomcat with a raw HTTP/2 client (content-length 10, 5 bytes written): without the change the response was HEADERS, DATA(5), DATA(0, END_STREAM); with it, HEADERS, DATA(5), RST_STREAM(PROTOCOL_ERROR). A response that matches its content length, HEAD, trailers and static files behave as before. The HTTP/2 test suite passes.