AngelHttp class
Adapts dart:io's HttpServer to serve Angel.
- Inheritance
-
- Object
- Driver<
HttpRequest, HttpResponse, HttpServer, HttpRequestContext, HttpResponseContext> - AngelHttp
Constructors
- AngelHttp(Angel app, {bool useZone = true})
-
factory
-
AngelHttp.custom(Angel app, ServerGeneratorType serverGenerator, {bool useZone = true, Map<
String, String> headers = const {}}) -
An instance mounted on a server started by the
serverGenerator.factory - AngelHttp.fromSecurityContext(Angel app, SecurityContext context, {bool useZone = true})
-
factory
- AngelHttp.secure(Angel app, String certificateChainPath, String serverKeyPath, {String? password, bool useZone = true})
-
Creates an HTTPS server.
factory
Properties
- app → Angel
-
finalinherited
- closeTimeout ↔ Duration
-
How long drain waits for the requests in progress to finish, before
it closes their connections.
getter/setter pairinherited
- hashCode → int
-
The hash code for this object.
no setterinherited
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- server ↔ HttpServer?
-
The native server running this instance.
getter/setter pairinherited
-
serverGenerator
→ Future<
HttpServer> Function(dynamic, int) -
The function used to bind this instance to a server..
finalinherited
- uri → Uri
-
The path at which this server is listening for requests.
no setteroverride
- useZone → bool
-
finalinherited
Methods
-
addCookies(
HttpResponse response, Iterable< Cookie> cookies) → void -
override
-
addResponseHeader(
Map< String, Object?> headers) → void -
Adds default headers to the server's responses, as
HttpHeadersValues.addValues does: each value of a list, skipping a
null. A header that a handler sets replaces one of the same name. -
close(
) → Future< void> -
Shuts down the underlying server: it is drained, then the shutdown
hooks run, and the app is closed.
override
-
closeResponse(
HttpResponse response) → Future -
override
-
closeServer(
HttpServer 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.override -
connectionsClosed(
) → Future< void> -
Waits until
dart:iohas closed every connection, as it does once its response is sent.override -
createRequestContext(
HttpRequest request, HttpResponse response) → Future< HttpRequestContext> -
override
-
createResponseContext(
HttpRequest request, HttpResponse response, [HttpRequestContext? correspondingRequest]) → Future< HttpResponseContext> -
override
-
createResponseStreamFromRawRequest(
HttpRequest request) → Stream< HttpResponse> -
override
-
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.
inherited
-
generateServer(
Object? address, int port) → Future< HttpServer> -
inherited
-
handleAngelHttpException(
AngelHttpException e, StackTrace st, RequestContext? req, ResponseContext? res, HttpRequest request, HttpResponse response, {bool ignoreFinalizers = false}) → Future -
Handles an AngelHttpException.
inherited
-
handleRawRequest(
HttpRequest request, HttpResponse response) → Future -
Handles a single request.
inherited
-
handleRawRequestSafely(
HttpRequest request, HttpResponse 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.
inherited
-
handleRequest(
HttpRequest request) → Future -
Handles
request, for use with a server created outside of startServer. Like handleRawRequestSafely, the returned future never fails: a malformed request gets400 Bad Request, and an error in the server500 Internal Server Error; both are logged. -
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
removeResponseHeader(
Map< String, Object?> headers) → void -
Removes the given default headers of the server's responses, as
HttpHeadersValues.removeValues does: a list removes each of its
values, a value matches exactly, or ignoring case if nothing matches
exactly, and a
nullvalue removes the header, whatever its values. -
sendResponse(
HttpRequest request, HttpResponse response, RequestContext req, ResponseContext res, {bool ignoreFinalizers = false}) → Future -
Sends a response.
inherited
-
setChunkedEncoding(
HttpResponse response, bool value) → void -
Asking for chunked encoding on an HTTP/1.0 response is ignored, as
those clients cannot receive it (see supportsChunkedEncoding); any
other failure is thrown.
override
-
setContentLength(
HttpResponse response, int length) → void -
override
-
setHeader(
HttpResponse response, String key, String value) → void -
override
-
setStatusCode(
HttpResponse response, int value) → void -
override
-
startServer(
[Object? address, int port = 0]) → Future< HttpServer> -
Starts, and returns the server.
inherited
-
supportsChunkedEncoding(
HttpRequest request) → bool -
HTTP/1.0 has no chunked encoding; Content-Length is sent instead.
override
-
toString(
) → String -
A string representation of this object.
inherited
-
writeStringToResponse(
HttpResponse response, String value) → void -
override
-
writeToResponse(
HttpResponse response, List< int> data) → void -
override
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited