Skip to content

feat(ldpreload): add HTTP/2 support via binary frame parsing and HPACK decoding#1

Merged
epli2 merged 3 commits into
mainfrom
claude/add-http2-support-cmUlq
Mar 1, 2026
Merged

feat(ldpreload): add HTTP/2 support via binary frame parsing and HPACK decoding#1
epli2 merged 3 commits into
mainfrom
claude/add-http2-support-cmUlq

Conversation

@epli2
Copy link
Copy Markdown
Owner

@epli2 epli2 commented Mar 1, 2026

  • Add hpack = "0.3" dependency to phantom-agent for HPACK header decompression
  • Detect HTTP/2 connections by the client connection preface (RFC 7540 §3.5)
  • Add H2Stream and H2ConnState structs for per-stream and per-connection state
  • Add FdState::Http2 variant to the existing connection state machine
  • Parse HTTP/2 HEADERS, DATA, and CONTINUATION frames in both send/recv directions
  • Strip PADDED and PRIORITY bytes from HEADERS frame payloads before HPACK decoding
  • Reconstruct URLs from :scheme, :authority, :path pseudo-headers
  • Emit completed streams on END_STREAM; emit partial streams on connection teardown
  • Add protocol_version field to TraceMsg ("HTTP/1.1" or "HTTP/2")
  • Update AgentTrace in ldpreload.rs to deserialize optional protocol_version
    for backward compatibility with older agents

https://claude.ai/code/session_014x4vABvvEiLpK7PfboZJar

claude added 3 commits March 1, 2026 13:39
…K decoding

- Add `hpack = "0.3"` dependency to phantom-agent for HPACK header decompression
- Detect HTTP/2 connections by the client connection preface (RFC 7540 §3.5)
- Add `H2Stream` and `H2ConnState` structs for per-stream and per-connection state
- Add `FdState::Http2` variant to the existing connection state machine
- Parse HTTP/2 HEADERS, DATA, and CONTINUATION frames in both send/recv directions
- Strip PADDED and PRIORITY bytes from HEADERS frame payloads before HPACK decoding
- Reconstruct URLs from `:scheme`, `:authority`, `:path` pseudo-headers
- Emit completed streams on END_STREAM; emit partial streams on connection teardown
- Add `protocol_version` field to `TraceMsg` ("HTTP/1.1" or "HTTP/2")
- Update `AgentTrace` in ldpreload.rs to deserialize optional `protocol_version`
  for backward compatibility with older agents

https://claude.ai/code/session_014x4vABvvEiLpK7PfboZJar
- Add `python3` to the Dockerfile runtime image for the minimal h2c server
- Add `start_mock_h2c()` helper to lib.sh: a stdlib-only Python 3 server that
  speaks HTTP/2 cleartext (h2c), handles SETTINGS exchange, and replies to
  GET/POST streams with a fixed JSON body
- Add test 11 — HTTP/2 cleartext GET: asserts protocol_version="HTTP/2",
  method, status_code, URL path, and response body
- Add test 12 — HTTP/2 cleartext POST: additionally asserts request_body capture
- Both tests use `curl --http2-prior-knowledge` and include a feature guard
  that skips gracefully if the curl binary lacks HTTP/2 support

https://claude.ai/code/session_014x4vABvvEiLpK7PfboZJar
Adds start_mock_h2tls() to lib.sh: a Python 3 stdlib server that wraps
the same HTTP/2 frame logic as start_mock_h2c in TLS via ssl.SSLContext,
advertising "h2" through ALPN so curl selects HTTP/2 without prior-knowledge.

Test 13 (HTTP/2 HTTPS ALPN) validates the SSL_write()/SSL_read() hook path:
after TLS negotiation the agent intercepts plaintext HTTP/2 frames and emits
a trace with protocol_version="HTTP/2", exercising the same route taken when
tracing real HTTPS/2 applications.

https://claude.ai/code/session_014x4vABvvEiLpK7PfboZJar
@epli2 epli2 merged commit a05715f into main Mar 1, 2026
3 checks passed
@epli2 epli2 deleted the claude/add-http2-support-cmUlq branch March 1, 2026 15:10
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.

2 participants