Skip to content

fix: record pushed request method for HEAD content-length checks - #1357

Closed
adityajai119 wants to merge 1 commit into
python-hyper:masterfrom
adityajai119:fix/pushed-stream-head-method
Closed

adityajai119 wants to merge 1 commit into
python-hyper:masterfrom
adityajai119:fix/pushed-stream-head-method

Conversation

@adityajai119

Copy link
Copy Markdown

A pushed stream never recorded the method from the PUSH_PROMISE request headers. As a result, a pushed stream whose request method is HEAD was treated as a normal request: a response carrying content-length plus an empty DATA frame with END_STREAM raised InvalidBodyLengthError even though RFC 9113 defines the response to HEAD as having no content.

H2Stream.remotely_pushed already stored :authority from the pushed headers; this records the method too so the existing HEAD exemption in _initialize_content_length applies to pushed streams.

Test: one focused in-memory H2Connection case (PUSH_PROMISE with :method: HEAD, response with content-length: 1234, empty DATA with END_STREAM). Before: InvalidBodyLengthError: Expected 1234 bytes, received 0. After: ResponseReceived and StreamEnded delivered. Narrow pytest: 415 passed. Ruff check passes on both changed files.

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.

1 participant