feat(ldpreload): add HTTP/2 support via binary frame parsing and HPACK decoding#1
Merged
Merged
Conversation
…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
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.
hpack = "0.3"dependency to phantom-agent for HPACK header decompressionH2StreamandH2ConnStatestructs for per-stream and per-connection stateFdState::Http2variant to the existing connection state machine:scheme,:authority,:pathpseudo-headersprotocol_versionfield toTraceMsg("HTTP/1.1" or "HTTP/2")AgentTracein ldpreload.rs to deserialize optionalprotocol_versionfor backward compatibility with older agents
https://claude.ai/code/session_014x4vABvvEiLpK7PfboZJar