TsgcHTTPServer › Properties › HTTP3Options
Enables the HTTP/3 (QUIC) listener that serves HTTP requests alongside HTTP/1.1 and HTTP/2, over UDP.
property HTTP3Options: TsgcWSHTTP3Server_Options read FHTTP3Options write SetHTTP3Options;
Enabled=False, Port=0, Host='', AltSvc.Enabled=True
By default the server does not listen for HTTP/3. Set HTTP3Options.Enabled to True to open a QUIC listener alongside the existing TCP/TLS listener; it requires the certificate and key already configured in SSLOptions (CertFile/KeyFile, plus Password when the private key is encrypted) and OpenSSL 3.5 or later. SSLOptions.IOHandler must be iohOpenSSL or iohNativeTLS, any other value raises an error when the listener starts. With iohNativeTLS the HTTP/3 listener runs on the sgc QUIC engine with the TLS 1.3 handshake on the native TLS engine and the packet protection on sgcCrypto, so it needs no OpenSSL, see SSL without OpenSSL. The HTTP/3 listener reads SSLOptions.Password exactly as the HTTPS listener does, so one CertFile/KeyFile/Password set serves both the TCP/TLS listener and the HTTP/3 listener. Port sets the UDP port the listener binds to; leave it at 0 to reuse the port already set in SSLOptions.Port. Host sets the address the listener binds to; leave it empty, the default, to bind every interface. It accepts an IPv4 address, an IPv6 address or a host name. The HTTP/3 listener owns a single UDP socket of its own and does not read Bindings, so that property cannot be used to place the listener on one interface. Requests arriving over HTTP/3 are dispatched through the same DocumentRoot static file serving and the same OnCommandGet and OnCommandOther events used for HTTP/1.1 and HTTP/2, so existing request-handling code mostly just works; two differences to code for: ARequestInfo.Version reports 'HTTP/3' for these requests, and the AContext parameter passed to the handler is nil (there is no TCP connection behind an HTTP/3 request), so any code that dereferences it must guard for this case. AltSvc.Enabled (on by default) makes HTTPS responses carry an Alt-Svc header advertising the HTTP/3 endpoint once the listener is running, so browsers and clients can discover it and switch over on their own; it combines with the HTTP/2 Alt-Svc advertisement into a single header when both are enabled. Authentication.Basic is enforced on HTTP/3 requests. Sessions, OAuth2, JWT and WebAuthn authentication and request forwarding need TCP connection state that an HTTP/3 request does not have, so they cannot be evaluated on this transport, and a server configured with one of those schemes refuses HTTP/3 requests with 401 rather than serving them unauthenticated. Configure Basic authentication if the HTTP/3 listener needs to serve authenticated requests. If the HTTP/3 listener fails to start — port in use, missing or invalid certificate, OpenSSL 3.5 not available — the regular HTTP/1.1 and HTTP/2 server keeps running unaffected and the failure is reported through OnException. Building with HTTP/3 support requires the HTTP3 pack compiler directive to be enabled.
oServer := TsgcHTTPServer.Create(nil);
oServer.SSL := true;
oServer.SSLOptions.CertFile := 'c:\certificates\mycert.pem';
oServer.SSLOptions.KeyFile := 'c:\certificates\mycert.pem';
oServer.HTTP3Options.Enabled := true;
oServer.Active := true;