Skip to content

Add HTTP/2 support with transparent ALPN negotiation#305

Draft
tonyfettes wants to merge 2 commits intomainfrom
haoxiang/http2
Draft

Add HTTP/2 support with transparent ALPN negotiation#305
tonyfettes wants to merge 2 commits intomainfrom
haoxiang/http2

Conversation

@tonyfettes
Copy link

Summary

  • Add HPACK header compression (src/hpack/): static/dynamic tables, Huffman coding, encoder/decoder per RFC 7541
  • Add HTTP/2 frame layer (src/http2/): frame parsing/serialization, settings negotiation, flow control with coroutine suspension, stream multiplexing, connection management with background read loop
  • Add TLS ALPN support for both OpenSSL and SChannel backends (client + server)
  • Integrate HTTP/2 into HTTP client: transparent h2 upgrade when ALPN negotiates "h2"
  • Integrate HTTP/2 into HTTP server: optional TLS config, automatic h2/http1.1 negotiation, task-group-based concurrent stream handling

Existing HTTP/1.1 behavior is unchanged. JS backend unaffected (uses native fetch which already supports h2).

Test plan

  • HPACK encode/decode with RFC 7541 Appendix C examples
  • Frame parse/serialize round-trips
  • Client↔server connection preface exchange and SETTINGS handshake
  • E2E loopback test with TLS + ALPN
  • Verify existing HTTP/1.1 tests still pass

🤖 Generated with Claude Code

@coveralls
Copy link

coveralls commented Feb 28, 2026

Pull Request Test Coverage Report for Build 76

Details

  • 456 of 842 (54.16%) changed or added relevant lines in 17 files are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage decreased (-6.2%) to 74.586%

Changes Missing Coverage Covered Lines Changed/Added Lines %
src/http2/flow_control.mbt 3 6 50.0%
src/hpack/dynamic_table.mbt 15 20 75.0%
src/tls/openssl.mbt 17 22 77.27%
src/hpack/huffman.mbt 33 40 82.5%
src/http2/settings.mbt 21 28 75.0%
src/tls/schannel.mbt 13 21 61.9%
src/http2/frame.mbt 37 48 77.08%
src/http2/client.mbt 14 28 50.0%
src/http2/stream.mbt 35 60 58.33%
src/http/client.mbt 34 60 56.67%
Totals Coverage Status
Change from base Build 52: -6.2%
Covered Lines: 2659
Relevant Lines: 3565

💛 - Coveralls

- Add HPACK header compression (RFC 7541) with Huffman coding
- Add HTTP/2 framing, flow control, settings, and stream management
- Add H2ClientConnection and H2ServerConnection with background read loops
- Integrate HTTP/2 into existing HTTP client/server via ALPN ("h2"/"http/1.1")
- Add ALPN support for both OpenSSL and Windows SChannel
- Add HTTP/2 trailer support and stream accessors
- Fix use-after-free in TLS read loop after connection close
… hang

When a socket was closed via IoHandle::close(), the fd was removed from
evloop.fds before closesocket() was called. The subsequent IOCP completion
for cancelled I/O was silently dropped by poll() because the fd was no
longer in the fds map, leaving coroutines in protect_from_cancel(suspend())
waiting forever.
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