Skip to content

fix(httpv1): rebuild a message whose body is empty (#1050) - #1054

Merged
JarryShaw merged 1 commit into
mainfrom
fix/1050-httpv1-empty-body
Oct 6, 2026
Merged

JarryShaw merged 1 commit into
mainfrom
fix/1050-httpv1-empty-body

Conversation

@JarryShaw

Copy link
Copy Markdown
Owner
  • Searched for similar pull requests
  • Followed the coding style (make pylint, make mypy, make isort) — not run locally
  • make test passes, and a test case covers the change — the touched modules only, not the full suite
  • Added a changelog entry under docs/source/changelog/ and regenerated CHANGELOG.md, if the change is user-visible

What is the purpose of your pull request?

  • fix — corrects a defect

Description of your pull request and other information

httpv1.HTTP.from_data(info) raised TypeError: can't concat NoneType to bytes for any message with an empty body. read stores an empty body as None, _make_data passed it through, and make concatenated it.

The fix is in _make_data: it now passes b'' to make when the body is None. info.body stays None because test_http_runtime.py and test_reassembly_end_to_end.py assert that value, and make keeps its bytes signature. HTTPv2 does not have this bug: DATA, HEADERS, SETTINGS, GOAWAY, CONTINUATION and unassigned frames with empty payloads already round-trip.

The new test_httpv1_from_data_round_trips_a_message_with_an_empty_body checks four cases: a request with headers, a headerless request, an empty-bodied response, and a response with a body as a regression guard. Without the fix, the first three fail with the TypeError. The changelog entry pin goes from 166 to the measured 167.

Closes #1050

@JarryShaw JarryShaw added fix Pull requests that fix a defect (fix: subject prefix) review: running A cross-review is in flight against the current head - no verdict yet labels Oct 6, 2026
@JarryShaw

Copy link
Copy Markdown
Owner Author

Cross-review verdict on ff6e9a8d0: GOOD TO GO (ran on Sonnet; author Opus).

  • Right layer. Only _make_data changes (httpv1.py:358). read and the public info.body is None contract stay as they were, pinned at test_http_runtime.py:41/77/88, test_reassembly_end_to_end.py:167/187 and test_http_unit.py:1062. make behaves as before for None, str and int bodies.
  • Byte-exact round trip for 9 messages: a request with an empty body plus headers, a headerless request, a 204, responses and requests with bodies, Content-Length: 0 both ways, a bare 200 OK, and HTTP/1.0.
  • HTTPv2 is unaffected. It has no None body path, and empty DATA and SETTINGS frames round-trip.
  • New test: errors 3 times on main (TypeError: can't concat NoneType to bytes) and passes on head.
  • Changelog: changelog_md.py --check is in step. The pin reads 167, matching a measured 167; main is at 166.

Not breaking. Not checked: chunked and gzip bodies, and the full suite.

@JarryShaw JarryShaw added review: good-to-go Cross-review at the current head says ready; CI state is separate and removed review: running A cross-review is in flight against the current head - no verdict yet labels Oct 6, 2026
@JarryShaw JarryShaw added this to the 1.5 milestone Oct 6, 2026
@JarryShaw
JarryShaw merged commit 88f6778 into main Oct 6, 2026
133 of 135 checks passed
@JarryShaw
JarryShaw deleted the fix/1050-httpv1-empty-body branch October 6, 2026 01:42
@JarryShaw JarryShaw removed the review: good-to-go Cross-review at the current head says ready; CI state is separate label Oct 6, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

fix Pull requests that fix a defect (fix: subject prefix)

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

httpv1: from_data fails on a message with an empty body

1 participant