# 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.

```gizlang
import * as Http3 from "gizlang:http3";
```

## Types

### `Server`

```gizlang
type Server
```

A QUIC listener: UDP datagrams in, HTTP/3 connections out.

Opaque: create and use it through this module's functions.

## Functions

### `supported`

```gizlang
function supported(): bool
```

Whether this host's OpenSSL has a QUIC server (3.5 or later); without it `open` fails.

Effects: fail, io.

### `open`

```gizlang
function open(credentials: Tls.Credentials, host: string, port: i64): Server throws IoError
```

Listens on UDP HOST:PORT ("" for every address, port 0 for any) with the certificate of CREDENTIALS.

Effects: fail, write, io.

### `serveTls`

```gizlang
function serveTls(sys: System, listener: Listener, credentials: Tls.Credentials, answer: (request: Http.Request) => Http.ReplyPlan, uploads: Option<Http.RequestHead>): i64 throws IoError
```

HTTPS 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`

```gizlang
function Server.port(self: Server): i64
```

The UDP port that the server listens on.

Effects: fail, io.

### `Server.close`

```gizlang
function Server.close(self: Server): void
```

Makes `serve` return after the replies in flight.

Effects: fail, write.

### `Server.serve`

```gizlang
function Server.serve(self: Server, sys: System, reply: (request: Http.Request) => Http.ReplyPlan, head: Option<Http.RequestHead>): i64
```

Runs 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.

