Module

whiplash/http3

src/whiplash/http3.pooka

HTTP/3, HTTP over QUIC streams (RFC 9114).

QUIC already multiplexes and flow-controls, so HTTP/3 is mostly frames on streams: one request per bidirectional stream, and three unidirectional streams each way for control, the QPACK encoder and the QPACK decoder. Connection follows them all, given the bytes QUIC delivers on each stream; it never sees a packet.

Extended CONNECT for WebSockets over HTTP/3 is RFC 9220.

API reference

enum

ErrorCode

src/whiplash/http3.pooka:25
enum ErrorCode

The error codes of RFC 9114 section 8.1.

variant

NoError

src/whiplash/http3.pooka:26
ErrorCode.NoError
variant

GeneralProtocolError

src/whiplash/http3.pooka:27
ErrorCode.GeneralProtocolError
variant

InternalError

src/whiplash/http3.pooka:28
ErrorCode.InternalError
variant

StreamCreationError

src/whiplash/http3.pooka:29
ErrorCode.StreamCreationError
variant

ClosedCriticalStream

src/whiplash/http3.pooka:30
ErrorCode.ClosedCriticalStream
variant

FrameUnexpected

src/whiplash/http3.pooka:31
ErrorCode.FrameUnexpected
variant

FrameError

src/whiplash/http3.pooka:32
ErrorCode.FrameError
variant

ExcessiveLoad

src/whiplash/http3.pooka:33
ErrorCode.ExcessiveLoad
variant

IdError

src/whiplash/http3.pooka:34
ErrorCode.IdError
variant

SettingsError

src/whiplash/http3.pooka:35
ErrorCode.SettingsError
variant

MissingSettings

src/whiplash/http3.pooka:36
ErrorCode.MissingSettings
variant

RequestRejected

src/whiplash/http3.pooka:37
ErrorCode.RequestRejected
variant

RequestCancelled

src/whiplash/http3.pooka:38
ErrorCode.RequestCancelled
variant

RequestIncomplete

src/whiplash/http3.pooka:39
ErrorCode.RequestIncomplete
variant

MessageError

src/whiplash/http3.pooka:40
ErrorCode.MessageError
variant

ConnectError

src/whiplash/http3.pooka:41
ErrorCode.ConnectError
variant

VersionFallback

src/whiplash/http3.pooka:42
ErrorCode.VersionFallback
variant

QpackDecompressionFailed

src/whiplash/http3.pooka:43
ErrorCode.QpackDecompressionFailed
variant

QpackEncoderStreamError

src/whiplash/http3.pooka:44
ErrorCode.QpackEncoderStreamError
variant

QpackDecoderStreamError

src/whiplash/http3.pooka:45
ErrorCode.QpackDecoderStreamError
function

error_code

src/whiplash/http3.pooka:49
error_code(code: ErrorCode) -> Int
INFERREDfn(whiplash/http3.ErrorCode) -> Int

An error code's number on the wire, from 0x100.

class

Frame

src/whiplash/http3.pooka:75
class Frame

One frame (section 7.2).

class

Data

src/whiplash/http3.pooka:77
class Data(data: BitArray) is Frame
field

data

src/whiplash/http3.pooka:77
data: BitArray
INFERREDBitArray
constructor

new

src/whiplash/http3.pooka:77
INFERREDfn(BitArray) -> whiplash/http3.Data
class

Headers

src/whiplash/http3.pooka:79
class Headers(section: BitArray) is Frame
field

section

src/whiplash/http3.pooka:79
section: BitArray
INFERREDBitArray
constructor

new

src/whiplash/http3.pooka:79
INFERREDfn(BitArray) -> whiplash/http3.Headers
class

CancelPush

src/whiplash/http3.pooka:81
class CancelPush(push: Int) is Frame
field

push

src/whiplash/http3.pooka:81
push: Int
INFERREDInt
constructor

new

src/whiplash/http3.pooka:81
INFERREDfn(Int) -> whiplash/http3.CancelPush
class

Settings

src/whiplash/http3.pooka:83
class Settings(settings: List(#(Int, Int))) is Frame
field

settings

src/whiplash/http3.pooka:83
settings: List(#(Int, Int))
INFERREDList(#(Int, Int))
constructor

new

src/whiplash/http3.pooka:83
INFERREDfn(List(#(Int, Int))) -> whiplash/http3.Settings
class

PushPromise

src/whiplash/http3.pooka:85
class PushPromise(push: Int, section: BitArray) is Frame
field

push

src/whiplash/http3.pooka:85
push: Int
INFERREDInt
field

section

src/whiplash/http3.pooka:85
section: BitArray
INFERREDBitArray
constructor

new

src/whiplash/http3.pooka:85
INFERREDfn(Int, BitArray) -> whiplash/http3.PushPromise
class

Goaway

src/whiplash/http3.pooka:87
class Goaway(id: Int) is Frame
field

id

src/whiplash/http3.pooka:87
id: Int
INFERREDInt
constructor

new

src/whiplash/http3.pooka:87
INFERREDfn(Int) -> whiplash/http3.Goaway
class

MaxPushId

src/whiplash/http3.pooka:89
class MaxPushId(push: Int) is Frame
field

push

src/whiplash/http3.pooka:89
push: Int
INFERREDInt
constructor

new

src/whiplash/http3.pooka:89
INFERREDfn(Int) -> whiplash/http3.MaxPushId
class

Unknown

src/whiplash/http3.pooka:93
class Unknown(kind: Int, payload: BitArray) is Frame

A frame of a type this end does not know, including the reserved "grease" types 0x1f * N + 0x21, which must be ignored.

field

kind

src/whiplash/http3.pooka:93
kind: Int
INFERREDInt
field

payload

src/whiplash/http3.pooka:93
payload: BitArray
INFERREDBitArray
constructor

new

src/whiplash/http3.pooka:93
INFERREDfn(Int, BitArray) -> whiplash/http3.Unknown
class

Http3Error

src/whiplash/http3.pooka:96
class Http3Error(code: ErrorCode, message: String)

A connection or stream error.

field

code

src/whiplash/http3.pooka:96
code: ErrorCode
field

message

src/whiplash/http3.pooka:96
message: String
INFERREDString
constructor

new

src/whiplash/http3.pooka:96
enum

StreamType

src/whiplash/http3.pooka:99
enum StreamType

The types of unidirectional streams (section 6.2).

variant

Control

src/whiplash/http3.pooka:100
StreamType.Control
variant

Push

src/whiplash/http3.pooka:101
StreamType.Push
variant

QpackEncoder

src/whiplash/http3.pooka:102
StreamType.QpackEncoder
variant

QpackDecoder

src/whiplash/http3.pooka:103
StreamType.QpackDecoder
function

decode_frame

src/whiplash/http3.pooka:108
decode_frame(bytes: BitArray) -> Result(Option(#(Frame, BitArray)), Http3Error)
INFERREDfn(BitArray) -> Result(Option(#(whiplash/http3.Frame, BitArray)), whiplash/http3.Http3Error)

One frame from the front of the bytes, and the rest. Ok(None) when it has not fully arrived.

function

encode_frame

src/whiplash/http3.pooka:123
encode_frame(frame: Frame) -> BitArray
INFERREDfn(whiplash/http3.Frame) -> BitArray
function

server_settings

src/whiplash/http3.pooka:148
server_settings() -> List(#(Int, Int))
INFERREDfn() -> List(#(Int, Int))

What a server announces: a 4 KiB QPACK dynamic table for the client's encoder, up to 16 request streams blocked on it, and extended CONNECT (RFC 9220).

function

decoder_stream

src/whiplash/http3.pooka:162
decoder_stream() -> Int
INFERREDfn() -> Int

The server's QPACK decoder stream: the second unidirectional stream it opens, after the control stream (3).

function

decoder_output

src/whiplash/http3.pooka:176
decoder_output(connection: Connection) -> #(BitArray, Connection)

Bytes for the server's QPACK decoder stream (RFC 9204 section 4.4): the stream type the first time, then Section Acknowledgements, Stream Cancellations and Insert Count Increments as field sections are decoded and insertions arrive. Send them on decoder_stream(); empty when there is nothing new.

Pooka
let #(bytes, h3) = http3.decoder_output(h3)
let c = quic.send(c, http3.decoder_stream(), bytes, False)
function

cancel

src/whiplash/http3.pooka:190
cancel(connection: Connection, stream: Int) -> Connection

The client abandoned a request stream: forget it, and if its HEADERS were waiting for insertions, tell the client's encoder (Stream Cancellation) so it stops counting on them.

class

Event

src/whiplash/http3.pooka:262
class Event

What happened, as the server sees it.

class

Request

src/whiplash/http3.pooka:264
class Request(stream: Int, fields: List(Field), end_stream: Bool) is Event
field

stream

src/whiplash/http3.pooka:264
stream: Int
INFERREDInt
field

fields

src/whiplash/http3.pooka:264
fields: List(Field)
INFERREDList(whiplash/hpack.Field)
field

end_stream

src/whiplash/http3.pooka:264
end_stream: Bool
INFERREDBool
constructor

new

src/whiplash/http3.pooka:264
INFERREDfn(Int, List(whiplash/hpack.Field), Bool) -> whiplash/http3.Request
class

Body

src/whiplash/http3.pooka:266
class Body(stream: Int, data: BitArray, end_stream: Bool) is Event
field

stream

src/whiplash/http3.pooka:266
stream: Int
INFERREDInt
field

data

src/whiplash/http3.pooka:266
data: BitArray
INFERREDBitArray
field

end_stream

src/whiplash/http3.pooka:266
end_stream: Bool
INFERREDBool
constructor

new

src/whiplash/http3.pooka:266
INFERREDfn(Int, BitArray, Bool) -> whiplash/http3.Body
class

PeerSettings

src/whiplash/http3.pooka:268
class PeerSettings(settings: List(#(Int, Int))) is Event
field

settings

src/whiplash/http3.pooka:268
settings: List(#(Int, Int))
INFERREDList(#(Int, Int))
constructor

new

src/whiplash/http3.pooka:268
INFERREDfn(List(#(Int, Int))) -> whiplash/http3.PeerSettings
class

PeerGoaway

src/whiplash/http3.pooka:270
class PeerGoaway(id: Int) is Event
field

id

src/whiplash/http3.pooka:270
id: Int
INFERREDInt
constructor

new

src/whiplash/http3.pooka:270
INFERREDfn(Int) -> whiplash/http3.PeerGoaway
class

RequestTrailers

src/whiplash/http3.pooka:272
class RequestTrailers(stream: Int, fields: List(Field)) is Event
field

stream

src/whiplash/http3.pooka:272
stream: Int
INFERREDInt
field

fields

src/whiplash/http3.pooka:272
fields: List(Field)
INFERREDList(whiplash/hpack.Field)
constructor

new

src/whiplash/http3.pooka:272
class

StreamEnd

src/whiplash/http3.pooka:275
class StreamEnd(stream: Int) is Event

FIN arriving separately, or following trailers/ignored extension frames.

field

stream

src/whiplash/http3.pooka:275
stream: Int
INFERREDInt
constructor

new

src/whiplash/http3.pooka:275
INFERREDfn(Int) -> whiplash/http3.StreamEnd
class

Connection

src/whiplash/http3.pooka:293
class Connection(
  decoder: qpack.Decoder,
  peer_settings: Option(List(#(Int, Int))),
  control_stream: Option(Int),
  streams: Dict(Int, _Stream),
  encoder_stream: Option(Int),
  decoder_stream: Option(Int),
  peer_goaway: Option(Int),
  closed: List(Int),
  last_request: Int,
  going_away: Bool,
  max_push: Int,
  qpack: _Qpack
)

One server-side HTTP/3 connection, above QUIC.

field

decoder

src/whiplash/http3.pooka:294
decoder: qpack.Decoder
field

peer_settings

src/whiplash/http3.pooka:295
peer_settings: Option(List(#(Int, Int)))
INFERREDOption(List(#(Int, Int)))
field

control_stream

src/whiplash/http3.pooka:296
control_stream: Option(Int)
INFERREDOption(Int)
field

streams

src/whiplash/http3.pooka:297
streams: Dict(Int, _Stream)
INFERRED$package/pooka_stdlib/pooka/dict.Dict(Int, whiplash/http3._Stream)
field

encoder_stream

src/whiplash/http3.pooka:298
encoder_stream: Option(Int)
INFERREDOption(Int)
field

decoder_stream

src/whiplash/http3.pooka:299
decoder_stream: Option(Int)
INFERREDOption(Int)
field

peer_goaway

src/whiplash/http3.pooka:300
peer_goaway: Option(Int)
INFERREDOption(Int)
field

closed

src/whiplash/http3.pooka:301
closed: List(Int)
INFERREDList(Int)
field

last_request

src/whiplash/http3.pooka:302
last_request: Int
INFERREDInt
field

going_away

src/whiplash/http3.pooka:303
going_away: Bool
INFERREDBool
field

max_push

src/whiplash/http3.pooka:304
max_push: Int
INFERREDInt
field

qpack

src/whiplash/http3.pooka:305
qpack: _Qpack
INFERREDwhiplash/http3._Qpack
constructor

new

src/whiplash/http3.pooka:294
INFERREDfn(whiplash/qpack.Decoder, Option(List(#(Int, Int))), Option(Int), $package/pooka_stdlib/pooka/dict.Dict(Int, whiplash/http3._Stream), Option(Int), Option(Int), Option(Int), List(Int), Int, Bool, Int, whiplash/http3._Qpack) -> whiplash/http3.Connection
function

server

src/whiplash/http3.pooka:323
server() -> #(Connection, BitArray)
INFERREDfn() -> #(whiplash/http3.Connection, BitArray)

A connection, and the bytes for the server's control stream: its type, then SETTINGS.

function

receive

src/whiplash/http3.pooka:344
receive(connection: Connection, stream: Int, bytes: BitArray, fin: Bool) -> Result(
  #(List(Event), Connection),
  Http3Error
)

Bytes QUIC delivered on a stream, with whether the stream ended.

function

respond

src/whiplash/http3.pooka:396
respond(status: Int, headers: List(Field)) -> BitArray
INFERREDfn(Int, List(whiplash/hpack.Field)) -> BitArray

A response's HEADERS frame, encoded with QPACK's static table.

function

respond_on

src/whiplash/http3.pooka:413
respond_on(
  connection: Connection,
  stream: Int,
  status: Int,
  headers: List(Field)
) -> #(BitArray, Connection)
INFERREDfn(whiplash/http3.Connection, Int, Int, List(whiplash/hpack.Field)) -> #(BitArray, whiplash/http3.Connection)

A response's HEADERS frame on stream, encoded with QPACK's dynamic table where the client allows one: fields it has acknowledged go as one indexed line, and fields worth repeating are inserted for later responses (see encoder_output).

Pooka
let #(head, h3) = http3.respond_on(h3, stream, 200, headers)
function

encoder_stream

src/whiplash/http3.pooka:443
encoder_stream() -> Int
INFERREDfn() -> Int

The server's QPACK encoder stream: the third unidirectional stream it opens, after the control (3) and decoder (7) streams.

function

encoder_output

src/whiplash/http3.pooka:451
encoder_output(connection: Connection) -> #(BitArray, Connection)

Bytes for the server's QPACK encoder stream (RFC 9204 section 4.3): its type and the table capacity once the client's SETTINGS allow a table, then insertions. Send them on encoder_stream() before the responses that follow; empty when there is nothing new.

function

data

src/whiplash/http3.pooka:463
data(bytes: BitArray) -> BitArray
INFERREDfn(BitArray) -> BitArray

A DATA frame.