Skip to content

Omit padding when the PADDED flag is unset - #174

Open
fhgffy wants to merge 1 commit into
python-hyper:masterfrom
fhgffy:fix-unflagged-padding-20261011
Open

fhgffy wants to merge 1 commit into
python-hyper:masterfrom
fhgffy:fix-unflagged-padding-20261011

Conversation

@fhgffy

@fhgffy fhgffy commented Oct 10, 2026

Copy link
Copy Markdown

When a frame has a nonzero pad_length without the PADDED flag, its serializer still appends zero bytes. A peer treats those bytes as application data or part of the header block, and a DATA frame's wire length no longer matches flow_controlled_length. Clearing PADDED on an already configured frame triggers the same behavior.

Only append the padding bytes when PADDED is set, matching the existing condition for the pad-length field. This covers DATA, HEADERS, and PUSH_PROMISE; the configured length remains available when the flag is enabled again.

The regression covers all three frame types, zero/one/maximum padding lengths, initial unpadded construction and clearing the flag, HEADERS priority data, and re-enabling padding. Twelve cases fail against the original source. The full suite (including the HTTP/2 frame test collection) passes 166 tests with 100% statement/branch coverage. Source Ruff, strict mypy, check-manifest, wheel/sdist builds, Twine checks, and the HTML documentation build pass on Python 3.12.2.

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