gizlang:http3
an HTTP/3 server (RFC 9114) over the QUIC of OpenSSL 3.5 or later (found at run time; supported says whether this host has it). A request is read whole (headers, then body) and answered as an HTTP/2 stream is: the same Request, ReplyPlan and Http.replyOn. Header fields use QPACK with the static table only (RFC 9204): the server announces a dynamic table of capacity 0. The engine runs in one task (Server.serve); each connection and each stream is a task of its own.
import * as Http3 from "gizlang:http3";Types
Server
type ServerA QUIC listener: UDP datagrams in, HTTP/3 connections out.
Opaque: create and use it through this module's functions.
Functions
supported
function supported(): boolWhether this host's OpenSSL has a QUIC server (3.5 or later); without it open fails.
Effects: fail, io.
open
function open(credentials: Tls.Credentials, host: string, port: i64): Server throws IoErrorListens on UDP HOST:PORT ("" for every address, port 0 for any) with the certificate of CREDENTIALS.
Effects: fail, write, io.
serveTls
function serveTls(sys: System, listener: Listener, credentials: Tls.Credentials, answer: (request: Http.Request) => Http.ReplyPlan, uploads: Option<Http.RequestHead>): i64 throws IoErrorHTTPS and HTTP/3 on LISTENER: the TCP connections get TLS with CREDENTIALS and speak HTTP/1.1 or HTTP/2 (the client chooses by ALPN), and, when this host's OpenSSL has a QUIC server, the same port number over UDP speaks HTTP/3; the TLS answers advertise it with Alt-Svc. ANSWER answers a request on all three. UPLOADS, when given, selects streamed exchanges from a request head (Http.serveStreamed). The status once serving ends (the listener closed).
Effects: fail, read, write, console, io.
Methods
Server.port
function Server.port(self: Server): i64The UDP port that the server listens on.
Effects: fail, io.
Server.close
function Server.close(self: Server): voidMakes serve return after the replies in flight.
Effects: fail, write.
Server.serve
function Server.serve(self: Server, sys: System, reply: (request: Http.Request) => Http.ReplyPlan, head: Option<Http.RequestHead>): i64Runs the engine and answers the requests of every connection with REPLY until close; the connections served. HEAD chooses the
requests whose bodies stream to the reply (as Http.serveStreamed).
Effects: fail, read, write, console, io.