API Reference
Python API
nhttp3.serve(app, **kwargs)
Serve an ASGI application over HTTP/3.
nhttp3.serve(app, host="0.0.0.0", port=4433, certfile="cert.pem", keyfile="key.pem")
nhttp3.Config
| Property | Type | Default | Description |
|---|---|---|---|
max_idle_timeout | float | 30.0 | Seconds before idle connection closes |
initial_max_data | int | 10M | Connection-level flow control window |
initial_max_stream_data_bidi_local | int | 1M | Per-stream flow control (local bidi) |
initial_max_streams_bidi | int | 100 | Max concurrent bidirectional streams |
initial_max_streams_uni | int | 100 | Max concurrent unidirectional streams |
enable_0rtt | bool | False | Enable 0-RTT early data |
nhttp3.Endpoint
ep = await nhttp3.Endpoint.bind(host, port, config)
conn = await ep.accept() # server
conn = await ep.connect(h, p) # client
nhttp3.Connection
send, recv = await conn.open_bidi_stream()
send = await conn.open_uni_stream()
conn.close(error_code=0)
nhttp3.SendStream / RecvStream
n = await send.write(data)
await send.finish()
data = await recv.read(max_bytes=65536)
Node.js / WASM API
nhttp3.version() // "0.1.0"
nhttp3.encode_headers(pairs) // Uint8Array (QPACK)
nhttp3.decode_headers(block) // Array<[string,string]>
nhttp3.encode_data_frame(data) // Uint8Array
nhttp3.encode_headers_frame(qpackBlock) // Uint8Array
nhttp3.encode_settings_frame() // Uint8Array
Rust API
See docs.rs/nhttp3 for full Rust API documentation (generated from source).