CustomServer class
A server that binder opens, with the dart:io HttpServer API:
dart:io itself, or another package.
await Dox().startServer(
server: CustomServer(
(int port, Object? address) => HttpServer.bind(
address ?? InternetAddress.anyIPv4,
port,
shared: true,
),
),
);
The binder sets up its own server: Dox gives it none of the settings
of AppConfig, and tls and http2 in the config stop the start.
Dox serves a native server the native way, an AdaptedServer (eg. a
DoxHttpServer) with its own adapter, and any other server the plain
dart:io way. The server of the main port decides it for all the
ports: give every port the same kind of server.
- Inheritance
-
- Object
- ServerAdapter
- IoServerAdapter
- CustomServer
Constructors
- CustomServer(ServerBinder binder)
-
const
Properties
- binder → ServerBinder
-
opens the server of one port
final
- hashCode → int
-
The hash code for this object.
no setterinherited
- needsReusePort → bool
-
True when each isolate binds its own listener on the port, with
SO_REUSEPORT. Windows has none: there one isolate serves. False: the
isolates of the process share one listener.
no setterinherited
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
Methods
-
addFile(
HttpResponse res, String path, int start, int length) → Future< void> ? -
Sends
lengthbytes of the file atpathfromstartas the body ofres. null when the server can not do it: Dart streams the file.inherited -
answerStarted(
HttpResponse res) → bool -
a closed
dart:ioresponse has sent its head tooinherited -
bind(
int port, Object? address, ServerSettings settings) → Future< HttpServer> -
A server on
portwithsettings.override -
checkTls(
ServerTls tls) → void -
Throws a
TlsExceptionwhen the files oftlsare bad.inherited -
closeGracefully(
HttpServer server) → Future< void> -
The
close()ofdart:iodoes not wait for the open requests: it waits here, until no connection has a request. WebSockets get 1001.inherited -
end(
HttpResponse res) → void -
sends
reswith no Future; another response is closedinherited -
ensureAvailable(
) → void -
Throws when the server can not run here, with the reason.
inherited
-
fixedHeaders(
HttpHeaders headers) → bool -
true when
headersare request headers of the server: they can not changeinherited -
grpcStream(
HttpRequest req) → GrpcStream? -
The gRPC call of
req, a request of the server. null when the server has no gRPC (eg. no HTTP/2): dox_grpc answers 505.inherited -
headSent(
HttpResponse res) → bool -
dart:iodoes not tell, but itsstatusCodesetter throws aStateErroronce the head is out. Only the error path asks.inherited -
heldBody(
HttpRequest req) → Uint8List? -
the whole body when the server holds it already, else null: it
streams
inherited
-
isTls(
HttpServer server) → bool -
true when
serverspeaks HTTPSinherited -
isWebSocketUpgrade(
HttpRequest req) → bool -
true when
reqasks for a WebSocket upgradeinherited -
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
openFile(
HttpRequest req, List< String> paths, String folder) → FutureOr<ServerFile?> -
Opens the first of
paths[1..]that is there, elsepaths[0]. null whenpaths[0]is not there (or no regular file), a FileSystemException when it can not be opened. Needs owns.inherited -
owns(
HttpResponse res) → bool -
True when
resis a response of the server: it copies the body when it ends (see takeBody) and sends files itself (see openFile).inherited -
path(
HttpRequest req) → String -
The path of
req, with no query. The same asreq.uri.path, with no Uri made.inherited -
plainQuery(
HttpRequest req) → String? -
the query text of a plain target, else null: read
uri.queryinherited -
readBody(
HttpRequest req, int max) → Future< Uint8List> ? -
The whole body of
reqwhen the server reads it with no Dart stream, else null: Dox reads the stream. For a body overmaxbytes, give null: Dox reads the stream and answers 413.inherited -
reloadCertificate(
HttpServer server) → Future< void> -
reads the certificate files of
serveragaininherited -
scheme(
HttpRequest req) → String? -
httpsorhttpfor a port that bind opened in this isolate, from the local port of the connection. null for a request of another server (eg. aCustomServer).inherited -
takeBody(
HttpResponse res) → void -
lets go of the body of
res, after it ended. Needs owns.inherited -
tlsFiles(
HttpServer server) → ServerTls? -
the TLS files of
server, else nullinherited -
toString(
) → String -
A string representation of this object.
inherited
-
trailers(
HttpResponse res) → HttpHeaders? -
The trailers of
res: they go out after the body on HTTP/2, and are dropped on HTTP/1.1. null when the server sends no trailers.inherited -
upgradeWebSocket(
HttpRequest req, String? protocol, int maxMessageSize) → Future< WebSocket> -
accepts the WebSocket upgrade of
reqinherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited