Skip to content

httpv1: a message with no header fields fails to parse #1041

Description

@JarryShaw

pcapkit.protocols.application.httpv1.HTTP rejects every HTTP/1 message that has no header fields, even though RFC 9112 allows zero (*( field-line CRLF )). Measured on main:

b'GET / HTTP/1.0\r\n\r\n'          -> ProtocolError: HTTP: invalid format   (httpv1.py:385)
b'HTTP/1.0 200 OK\r\n\r\nbody'     -> ProtocolError: HTTP: invalid format   (httpv1.py:385)
b'GET / HTTP/1.1\r\nHost: x\r\n\r\n' -> OK

Cause: _read_http_header (httpv1.py:381-385) does header.split(b'\r\n', 1) and treats a missing CRLF as malformed. A message without headers has a header block that is only the start line, so the two-way unpacking fails.

Round trip is broken too. HTTP.make(method='GET', uri='/', http_version='1.1') produces b'GET / HTTP/1.1\r\n\r\n', which the reader then rejects. So HTTPv1(method='GET', uri='/', http_version='1.1') raises.

Fix: treat a header block with no CRLF as a start line with zero fields. Keep the HTTP/2-preface rejection that the comment above the split depends on. Add tests for a headerless request, a headerless response with a body, and the make→read round trip.

Blocked on #1039, an open docstring-only PR (#719 sweep) that edits httpv1.py. Starts once #1039 merges or closes. Found while reviewing #1039.

Activity

  1. added
    fixPull requests that fix a defect (fix: subject prefix)
    blockedDeferred pending another issue or decision; see the last comment for what unblocks it
    on Oct 5, 2026
  2. JarryShaw commented on Oct 5, 2026

    @JarryShaw
    OwnerAuthor

    Unblocked: #1039 merged. A worker is on the fix now.

  3. added
    wipWork in flight - a covering PR is open or an agent is actively on it
    and removed
    blockedDeferred pending another issue or decision; see the last comment for what unblocks it
    on Oct 5, 2026
  4. removed
    wipWork in flight - a covering PR is open or an agent is actively on it
    on Oct 5, 2026
  5. added this to the 1.5 milestone on Oct 6, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

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

    Projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions