Repository navigation
fix(http): HTTP.from_data raises 'invalid HTTP version: 0' - #1162
Merged
Merged
Conversation
- http: _make_data read a `version` key that neither HTTP/1.* nor HTTP/2 data carries; dispatch on the data class instead, and return the `version` that make() dispatches on. - httpv2: _make_data returned the frame's `length`, which ProtocolBase.__init__ took as the parse length (payload only, nine octets short), so every HTTP/2 from_data raised; make() computes the Length itself, so the key is dropped. - tests: new test_http_from_data_1154_unit; two test_http_unit cases that drove _make_data with a fake `version` key now use parsed data. Closes #1154
3 of 5 tasks
Owner
Author
|
Cross-review verdict on
|
3 of 5 tasks
Contributor
|
Coverage: 88.87% (unit tier, Python 3.14,
Per-file detail: the |
JarryShaw
added a commit
that referenced
this pull request
Oct 7, 2026
- 4 new 1.5.0 entries: HTTP/2 sample stream identifiers (#1161), TCP option re-padding (#1163, breaking), format='pcap' output (#1164), declared lengths on truncated captures (#1166, breaking) - extend the PCAP Header (#1159), HIP (#1160) and from_data round-trip (#1162) entries rather than duplicating them - regenerate CHANGELOG.md with util/changelog_md.py - process.rst: entry-count pin re-measured, 189 -> 193 tests/project: conventions_doc_claims, changelog_md and documentation_claims pass; changelog_md.py --check is in step.
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.
Please follow the guide below
make pylint,make mypy,make isort) — ran pylint (Makefile flags), mypy and isort on the two touched files directly, not viamake; no new findings beyond the existingprotected-accesspatternmake testpasses, and a test case covers the change — the modules listed below only, not the full suiteWhat is the purpose of your pull request?
fix— corrects a defectDescription of your pull request and other information
Closes #1154.
http.HTTP._make_datalooked up aversionkey that neither versioned data class has, so it always raisedinvalid HTTP version: 0. It now dispatches on the data class and returns theversionthatmakeneeds.httpv2.HTTP._make_datareturnedlength, whichProtocolBase.__init__takes as the parse length (payload only), so HTTP/2from_datafailed even directly (packet (6 octet(s)) shorter than the 9-octet frame header). Dropped;makecomputes the Length.test_http_unitcases drove_make_datawith a fakeversionkey (and pinnedlength); they now use parsed data.Probe,
HTTP.from_data(frame['HTTP'].info)over the captures: before, 222/4/5 ×invalid HTTP version: 0(http/options-transport/test.pcap). After, all 231 rebuild byte-exact with equalinfo.New
test_http_from_data_1154_unit: 4 passed, 31 subtests. Without both fixes: 32 failed, 3 passed. Without only the httpv2 fix: 28 failed. Also passing:test_http_unit,test_http_guess_http2_1141_unit,test_http_runtime, fourtest_httpv2_*,test_construction_keyword_check_unit,test_option_roundtrip_unit,test_tcp_http_dispatch_unit,test_frame_from_data_runtime,tests/project(389 passed, 1 skipped).