1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
//! HTTP/3 client over lsquic via packages/bun-usockets/src/quic.c.
//!
//! One `ClientContext` per HTTP-thread loop wraps the lsquic client engine;
//! each `ClientSession` is one QUIC connection to an origin and multiplexes
//! `Stream`s, each bound 1:1 to an `HTTPClient`. The result-delivery surface
//! is the same one H2 uses (`handleResponseMetadata` / `handleResponseBody` /
//! `progressUpdateH3`), so redirect, decompression, and FetchTasklet plumbing
//! are shared with HTTP/1.1.
//!
//! Layout mirrors `h2_client/`:
//! - `Stream` — one in-flight request
//! - `ClientSession` — one QUIC connection (pooled per origin)
//! - `ClientContext` — process-global lsquic engine + session registry
//! - `encode` — request header/body framing onto a quic.Stream
//! - `callbacks` — lsquic → Rust glue (on_hsk_done / on_stream_* / …)
//! - `PendingConnect` — DNS-pending connect resolution
use AtomicU32;
// Single `Output.scoped(.h3_client, .hidden)` for the whole module tree. Zig
// comptime-deduplicates per tag, so the four submodules share one
// `really_disable`/`is_visible_once`/lock; declaring it once here and importing
// in each child preserves that behavior.
declare_scope!;
pub use ClientContext;
pub use ClientSession;
pub use PendingConnect;
pub use Stream;
/// Live-object counters for the leak test in fetch-http3-client.test.ts.
/// Incremented at allocation, decremented in deinit. Read from the JS thread
/// via TestingAPIs.quicLiveCounts so they must be atomic.
// PORT NOTE: Zig names are `live_sessions`/`live_streams` (snake_case module
// vars). Kept verbatim so cross-crate readers (`bun_http_jsc`) and the gated
// submodules see the same identifier the Zig uses; SCREAMING_SNAKE aliases
// preserved for the existing internal references.
pub static live_sessions: AtomicU32 = new;
pub static live_streams: AtomicU32 = new;
pub use live_sessions as LIVE_SESSIONS;
pub use live_streams as LIVE_STREAMS;
// Zig: pub const TestingAPIs = @import("../http_jsc/headers_jsc.zig").H3TestingAPIs;
// Deleted per PORTING.md — *_jsc aliases are dropped; H3TestingAPIs lives in
// bun_http_jsc and is accessed via the extension-trait pattern there.
// ported from: src/http/H3Client.zig