Skip to content

Add an opt-in self-contained HTTP/2 WebSocket client - #674

Open
bsergean wants to merge 7 commits into
masterfrom
feature/h2-client
Open

bsergean wants to merge 7 commits into
masterfrom
feature/h2-client

Conversation

@bsergean

@bsergean bsergean commented Nov 23, 2026 •

Copy link
Copy Markdown
Collaborator

Adds an explicit RFC 8441 client path: WebSocket::setHttp2(true) or ws connect wss://host/path --http2. Each WebSocket owns one TLS/H2 connection and stream; HTTP/1.1 remains the default. This follows the proxy integration coverage in #671.

WebSocketTransport consumes a WebSocketStream byte stream. HTTP/1.1 uses SocketStream; HTTP/2 uses Http2Stream backed by Http2Connection, which owns the real TCP/TLS socket. Neither HTTP/2 class inherits from Socket. WebSocket framing, compression, callbacks, ping/pong and close handling use the same stream interface in both modes. Existing socket/TLS classes retain descriptor ownership, connection setup and socket I/O.

The implementation is self-contained C++11: HPACK decoding (dynamic tables and Huffman), never-indexed request encoding, HTTP/2 framing, Extended CONNECT negotiation, bounded buffering, flow control and cancellation. ALPN uses the existing TLS backends. No HTTP/2 production dependency is added.

Scope: experimental client only, wss:// with ALPN h2 and peer Extended CONNECT support. No pooling, multiplexing, cleartext H2, HTTP/2 server, or silent HTTP/1.1 fallback. See docs/http2.md.

Validation after the stream refactor:

  • Full OpenSSL regression suite: 39/39 tests passed.
  • Fast in-memory H2/HPACK and stream tests: 1,037 assertions in 16 cases; AddressSanitizer/UBSan pass. The tests verify that neither HTTP/2 class derives from Socket and exercise I/O, readiness, interruption and close through the common stream interface.
  • Focused ThreadSanitizer checks pass for H2, HTTP-to-WebSocket handoff, reconnection and send failures.
  • Docker/nghttpx integration passes: four native compression/close combinations, independent TLS/H2 peer (duplex 256 KiB transfers, blocked-send cancellation and ALPN rejection), plus Python proxy/multiplexing coverage. Proxy logs verify actual HTTP/2 connections.
  • Independent peer checks pass with OpenSSL 1.1/3.6, mbedTLS 3/4, Network.framework and SecureTransport. Network.framework builds with deprecated declarations treated as errors. SecureTransport uses test-only verification disabling because it cannot load the fixture's private CA; other backends verify the fixture CA/hostname.
  • C++11 pedantic builds and clang-format pass. Blank lines between definitions are enforced by SeparateDefinitionBlocks: Always.

CI retains assertion output and Docker exit/OOM diagnostics. Server compliance runs in fresh 64-case batches to limit accumulated Python-runner memory; every selected case/report remains mandatory, with the same overall timeout. Batch coverage tests pass. The h2-proxy and autobahn labels request integration and HTTP/1.1 compliance regression checks.

The mbedTLS CI failure exposed a shutdown race shared by both transports: stop() sets the stop flag before close() enters CLOSING, and the worker could exit in that gap without a Close callback. The worker now continues polling/dispatching until CLOSED; the stop flag still prevents reconnection. A deterministic, sleep-free regression test fails on the old code and passes with the fix. The upgrade suite passed 100 consecutive ThreadSanitizer runs after the fix, as did the full 39-test regression suite, ASan, H2 proxy checks and Network.framework peer tests.

@bsergean bsergean added autobahn Run the Docker Autobahn client and server compliance check h2-proxy Run HTTP/2 WebSocket reverse-proxy integration tests labels Nov 23, 2026

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

autobahn Run the Docker Autobahn client and server compliance check h2-proxy Run HTTP/2 WebSocket reverse-proxy integration tests

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant