Repository navigation
Conversation
- Add xHttpVersion_H3 to enum, map to CURL_HTTP_VERSION_3 - Add FindNgtcp2.cmake / FindNghttp3.cmake modules - Update FindLibcurl.cmake to auto-detect ngtcp2+nghttp3 for source builds - Add H3 client tests (ConfigGet/Post/ClientDefault/ConfigSse) - Update TODO.md with client-side H3 steps completed
Architecture: reuses xHttpProto vtable + xTlsConf. H3 connections share a single UDP socket, multiplexed by QUIC Connection ID. New files: - server_quic.c: UDP listener, ngtcp2 callbacks, QUIC connection lifecycle (handshake, packet I/O, CID routing, timers) - proto_h3.c / proto_h3.h: HTTP/3 protocol handler behind xHttpProto vtable, modeled after proto_h2.c (~400 lines) - /cmake: XHTTP_ENABLE_H3 option, auto-detects ngtcp2+nghttp3+OpenSSL Modified files: - server_private.h: H3 fields on xHttpConn_ (quic_conn, CID, timer, remote_addr) and xHttpServer_ (h3_listen_fd, quic_conns map) - server.h: xHttpServerListenH3() API — reuses xTlsConf - server.c: H3 cleanup in destroy/close, field init - CMakeLists.txt: conditional H3 compilation + linking Known gaps (marked with FIXME in code): - proto_h3.c stream_id routing in on_data - Response body delivery - Streaming write_data / end_stream stubs - Per-stream method retrieval This is a first-pass architectural scaffold. The QUIC listener, handshake, CID routing, and protocol handler vtable plumbing are functional skeletons.
- proto_h3.c: rewrite response path using nghttp3_conn_writev_stream + ngtcp2_conn_writev_stream_versioned (explicit serialization model) - proto_h3.c: add h3_flush_responses() to serialize and send after each submit_response/write_data call - proto_h3.c: body delivery via nghttp3_data_reader callback - server_quic.c: fix all 16 compilation errors: * xClockMonotonicNs -> clock_gettime(CLOCK_MONOTONIC) * acked_stream_data_offset callback signature (4-param version) * settings.max_idle_timeout_ms -> removed (field doesn't exist in 1.24) * transport_params.max_idle_timeout_ms -> max_idle_timeout * timer callback type: void(void*) not void(xEventTimer,void*) * ngtcp2_conn_write_pkt_versioned has no flags param * NGTCP2_ERR_WOULDBLOCK -> NGTCP2_ERR_WRITE_MORE * xErrno_Already/System -> AlreadyExists/InvalidArg * xSocketDestroy needs 2 args * xMapType_Default -> xMapType_Hash - server_private.h: add #include <sys/socket.h> for sockaddr_storage - server.c: add #include <x/base/map.h> for xMapDel - cmake/FindNgtcp2.cmake: fix lib name ngtcp2_crypto_openssl->ossl Test results: 149/149 non-client tests pass. H3 client tests (4/4) pass. HttpClientTest failures (6) are pre-existing port conflict issues.
- Add xHttpServerListenH3 to Lifecycle table in server.md - Update configuration note to include ListenH3
Server-side: - xHttpServer_::alt_svc[128] — built in xHttpServerListenH3() - xHttpResponseSend injects Alt-Svc header on TLS connections when H3 is enabled (conn->handshake_done && !conn->is_quic) - RFC 9114 §3.1.1: only on encrypted connections, not on H3 itself Tests: - ServerH3Test.H3ListenSucceeds — verify H3 UDP listener starts - ServerH3Test.ListenH3TwiceReturnsAlreadyExists - CMakeLists.txt: propagate X_HAS_NGHTTP3 to test target Test results: 151/151 non-client tests pass (6/6 H3 tests pass).
Core fixes: - proto vtable on_data: add int64_t stream_id parameter (needed for H3 multi-stream routing via nghttp3_conn_read_stream) - proto_h1.c / proto_h2.c: accept stream_id (unused, pass 0) - proto_h3.c: use stream_id in nghttp3_conn_read_stream - proto_h3.c: fix h3_body_read to work via per-stream xH3StreamData - proto_h3.c: fix h3_write_data streaming with h3_body_read callback - server.c: pass stream_id=0 for H1/H2 on_data calls - server_quic.c: pass actual stream_id from ngtcp2 recv_stream_data_cb - CMakeLists.txt: add XHTTP_TEST_SRC_DIR for cert file paths Integration tests: - server_h3_test.cpp: H3 end-to-end tests via curl --http3 (CurlH3Get, CurlH3PostEcho — skipped in CI, for manual validation) - h3_test_cert.pem / h3_test_key.pem: self-signed TLS certs for testing Test results: 151/153 tests pass (2 integration tests skipped).
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.
Summary
Add HTTP/3 support to xhttp, using the ngtcp2 + nghttp3 stack (same stack as libcurl HTTP/3, already available via brew).
Client-side (xHttpVersion_H3)
xHttpVersion_H3 = 5, maps toCURL_HTTP_VERSION_3Server-side (xHttpServerListenH3)
xHttpServerListenH3(server, host, port, xTlsConf)— reuses xTlsConfserver_quic.c: UDP listener, ngtcp2 callbacks, QUIC handshake (TLS 1.3 via OpenSSL)proto_h3.c: nghttp3 protocol handler behind xHttpProto vtable (~450 lines)Test results
Files changed
server_quic.cproto_h3.cproto_h3.hserver_h3_test.cppserver_private.hserver.hxHttpServerListenH3()APIserver.cclient.h/client.cxHttpVersion_H3CMakeLists.txtXHTTP_ENABLE_H3optioncmake/FindNgtcp2.cmakecmake/FindNghttp3.cmakehttp_test.cppserver_h1_test.cppTODO.mddocs/libx/http/server.mdscripts/export-allowlist.txtDesign decisions