Skip to content

fix: record request method for pushed HEAD streams - #1354

Open
feiiiiii5 wants to merge 1 commit into
python-hyper:masterfrom
feiiiiii5:feiiiiii5/D234
Open

feiiiiii5 wants to merge 1 commit into
python-hyper:masterfrom
feiiiiii5:feiiiiii5/D234

Conversation

@feiiiiii5

Copy link
Copy Markdown

Related to #1330 (our open PR #1344 explicitly leaves the pushed-HEAD case out of scope).

A server push whose request uses :method: HEAD is treated like GET, so a valid bodyless pushed 200 with content-length: 5 is rejected with InvalidBodyLengthError: Expected 5 bytes, received 0.

Root cause

H2Stream.remotely_pushed() set _authority but never set request_method, so _initialize_content_length() could not apply the HEAD exemption. send_headers() already sets it for normal requests.

Fix

Set self.request_method = extract_method_header(pushed_headers) in remotely_pushed(). One line, no new branch.

Verification

  • New TestPushedHeadRequest with HEAD and GET controls. Base-red: HEAD case failed with InvalidBodyLengthError, GET control passed (1 failed / 1 passed).
  • With fix: 6 tests in the module passed; full suite 1686 passed with 100% statement and branch coverage (repo fail_under=100 satisfied).
  • ruff check src/: clean. mypy --strict src/ and --strict-bytes: clean.

A pre-existing Hypothesis differing_executors health check in test_invalid_headers.py was suppressed externally for the full run; no repo file was changed for it.

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