Driver<Request, Response, Server extends Stream<Request> , RequestContextType extends RequestContext, ResponseContextType extends ResponseContext> class
abstract
Base driver class for Angel implementations.
Powers both AngelHttp and AngelHttp2.
- Implementers
Properties
- app → Angel
-
final
- closeTimeout ↔ Duration
-
How long drain waits for the requests in progress to finish, before
it closes their connections.
getter/setter pair
- hashCode → int
-
The hash code for this object.
no setterinherited
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- server ↔ Server?
-
The native server running this instance.
getter/setter pair
-
serverGenerator
→ Future<
Server> Function(dynamic, int) -
The function used to bind this instance to a server..
final
- uri → Uri
-
The path at which this server is listening for requests.
no setter
- useZone → bool
-
final
Methods
-
addCookies(
Response response, Iterable< Cookie> cookies) → void -
close(
) → Future< void> - Shuts down the underlying server: it is drained, then the shutdown hooks run, and the app is closed.
-
closeResponse(
Response response) → Future -
closeServer(
Server server) → Future< void> -
Closes a
servercreated by generateServer, with its connections: one that never started serving (see startServer), or one whose requests did not finish within closeTimeout (see drain). Drivers whose server can be closed should override this; the default does nothing. -
connectionsClosed(
) → Future< void> - Completes once the connections of the server are closed, after drain stopped accepting requests and those in progress finished: a response that has been sent may still be being written to its socket, which ending the process (or isolate) right away would cut off. drain waits for it within closeTimeout. The default completes at once.
-
createRequestContext(
Request request, Response response) → Future< RequestContextType> -
createResponseContext(
Request request, Response response, [RequestContextType? correspondingRequest]) → Future< ResponseContextType> -
createResponseStreamFromRawRequest(
Request request) → Stream< Response> -
drain(
) → Future< void> - Stops accepting requests, and waits up to closeTimeout for those in progress to finish, and their connections to close (see connectionsClosed); any still open then are closed (see closeServer). Unlike close, it neither runs the shutdown hooks nor closes the app, so that a driver that shares its app with another (as AngelHttp2 does for HTTP/1) can be drained alongside it. Calling it again returns the same future.
-
generateServer(
Object? address, int port) → Future< Server> -
handleAngelHttpException(
AngelHttpException e, StackTrace st, RequestContext? req, ResponseContext? res, Request request, Response response, {bool ignoreFinalizers = false}) → Future - Handles an AngelHttpException.
-
handleRawRequest(
Request request, Response response) → Future - Handles a single request.
-
handleRawRequestSafely(
Request request, Response response) → Future< void> - Like handleRawRequest, but never fails: errors that happen outside the per-request error zone are logged and answered, since left unhandled they would terminate the whole server.
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
sendResponse(
Request request, Response response, RequestContext req, ResponseContext res, {bool ignoreFinalizers = false}) → Future - Sends a response.
-
setChunkedEncoding(
Response response, bool value) → void -
setContentLength(
Response response, int length) → void -
setHeader(
Response response, String key, String value) → void -
setStatusCode(
Response response, int value) → void -
startServer(
[Object? address, int port = 0]) → Future< Server> - Starts, and returns the server.
-
supportsChunkedEncoding(
Request request) → bool -
Whether the client of
requestcan receive a chunked response; HTTP/1.0 clients cannot, so a driver for them overrides this. -
toString(
) → String -
A string representation of this object.
inherited
-
writeStringToResponse(
Response response, String value) → void -
writeToResponse(
Response response, List< int> data) → void
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited
Static Methods
-
runPipeline<
RequestContextType extends RequestContext, ResponseContextType extends ResponseContext> (MiddlewarePipelineIterator< RequestHandler> it, RequestContextType req, ResponseContextType res, Angel app) → Future<void> - Runs a MiddlewarePipeline.