the http server: a NativeHttpServer (dox_http_native, Rust owns
the sockets, the default), or the server of the ServerAdapter of
startServer(server:). All have the dart:ioHttpServer API.
Stops the start when the files of AppConfig.tls, or of a port of
AppConfig.ports, are bad: it throws a TlsException.
Dox().startServer() runs it once, before any isolate starts. Else
each isolate fails on its own and is started again, in a loop. It
does nothing when no port has tls, and for a CustomServer.
Reads the certificate and key files of AppConfig.tls, and of each
port of AppConfig.ports with tls, again, for example after
certbot renewed them. New connections get the new
certificate. Open connections keep the old one until they close.
One call is enough: every isolate of the process gets it. When a
file is bad, it throws a TlsException and the server keeps the old
certificate. With more than one certificate, it checks all the
files first, so a bad file changes no port. A file that changes
between the check and the reload can still stop it half way: then
call it again. It throws a StateError when no port has tls, before
the server starts and after it is closed. Dox does not watch the files:
the app decides when to call it (eg. on SIGHUP).
The server work of this isolate: the adapter of the type of the
server. listen sets it, before the first request. Before that (eg.
a request object in a unit test) it is the native one.
true when a response may set its content length: the server does not
gzip (a server gzips only when no length is set). listen sets it
from the server, so the autoCompress of a binder counts too.
Before that (a unit test): from compress of the config.
Throws an ArgumentError when server is a CustomServer and
config asks for tls or http2, on the main port or on a port of
AppConfig.ports. Its binder sets them on its own server.
It also throws for BuiltInServer.ioHttpServer with http2:
dart:io has no HTTP/2.
Throws an ArgumentError when an app with ports lists a port two
times, in port, additional and ports together. Such a port
would be bound two times (the OS allows it), with two kinds of
settings. Port 0 is a free port each time, so it can repeat. With no
ports it checks nothing, as before AppConfig.ports.
Dox().startServer() runs it once, before any isolate starts. Else
each isolate fails on its own and is started again, in a loop.
The port to listen on. APP_PORT in the env means configured (the
app reads it into serverPort). With no APP_PORT, PORT wins:
Cloud Run, Fly, Render and Heroku tell the app its port with it.