we (web engine): Experimental web browser project to understand the limits of Claude

HTTP/1.1 parser: request/response, headers, chunked encoding #62

open opened by pierrelf.com

Phase 6: HTTP/1.1 Parser#

Implement HTTP/1.1 message parsing in the net crate (RFC 7230, 7231).

Requirements#

  • Request serialization:
    • Request line: METHOD SP Request-URI SP HTTP/1.1 CRLF
    • Headers: field-name: field-value CRLF
    • Required headers: Host, User-Agent, Accept, Connection
    • Optional: Content-Length, Content-Type for request bodies
  • Response parsing:
    • Status line: HTTP/1.1 SP status-code SP reason-phrase CRLF
    • Header parsing: case-insensitive field names, multi-line values
    • HttpResponse { status_code, headers, body } type
  • Transfer-Encoding: chunked (RFC 7230 ยง4.1):
    • Parse chunk-size (hex) CRLF chunk-data CRLF
    • Handle last-chunk (size 0) and optional trailers
    • Dechunk response body transparently
  • Content-Length handling: read exact number of body bytes
  • Header types: Headers collection with case-insensitive lookup
  • Content-Type parsing: extract MIME type and charset parameter

Dependencies#

  • None (pure parsing, no I/O)

Acceptance Criteria#

  • Serialize HTTP/1.1 GET and POST requests
  • Parse HTTP/1.1 response status lines
  • Parse headers with case-insensitive lookup
  • Handle Content-Length bodies
  • Handle chunked Transfer-Encoding
  • Handle responses with no body (204, 304)
  • Parse Content-Type with charset
  • Edge cases: empty body, zero Content-Length, missing Content-Length with chunked
  • Comprehensive tests (30+ tests)
  • cargo clippy and cargo fmt clean
sign up or login to add to the discussion
Labels

None yet.

assignee

None yet.

Participants 1
AT URI
at://did:plc:meotu43t6usg4qdwzenk4s2t/sh.tangled.repo.issue/3mguym3gawi2g