AngelHttp2 class
Adapts package:http2's ServerTransportConnection to serve Angel.
- Inheritance
-
- Object
- Driver<
Socket, ServerTransportStream, SecureServerSocket, Http2RequestContext, Http2ResponseContext> - AngelHttp2
Constructors
- AngelHttp2(Angel app, SecurityContext securityContext, {bool useZone = true, bool allowHttp1 = false, ServerSettings? settings, Duration sessionTimeout = const Duration(minutes: 20)})
-
factory
-
AngelHttp2.custom(Angel app, SecurityContext ctx, Future<
SecureServerSocket> serverGenerator(InternetAddress? address, int port, SecurityContext ctx), {bool useZone = true, bool allowHttp1 = false, ServerSettings? settings, Duration sessionTimeout = const Duration(minutes: 20)}) -
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
-
onHttp1
→ Stream<
HttpRequest> -
Fires when an HTTP/1.x request is received.
no setter
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- server ↔ SecureServerSocket?
-
The native server running this instance.
getter/setter pairinherited
-
serverGenerator
→ Future<
SecureServerSocket> Function(dynamic, int) -
The function used to bind this instance to a server..
finalinherited
- sessionTimeout → Duration
-
How long a session may go unused before it is discarded.
final
- settings → ServerSettings?
-
final
- socket → SecureServerSocket?
-
no setter
- uri → Uri
-
The path at which this server is listening for requests.
no setteroverride
- useZone → bool
-
finalinherited
Methods
-
addCookies(
ServerTransportStream response, Iterable< Cookie> cookies) → void -
override
-
addResponseHeader(
Map< String, Object?> headers) → void -
Adds default headers to the responses, HTTP/2 ones and those of the
HTTP/1 requests that
allowHttp1serves, by the rules of AngelHttp.addResponseHeader: a header that a handler sets replaces one of the same name. Unlike that one, it may be called before startServer too. -
close(
) → Future< void> -
Shuts down the underlying server: it is drained, then the shutdown
hooks run, and the app is closed.
inherited
-
closeResponse(
ServerTransportStream response) → Future -
Ends a stream the driver wrote to (see
_pending). A stream it never wrote to is reset instead, since no valid response can be sent on it, as is one whose Http2ResponseContext sent its own headers but not those of the driver (e.g. an error fallback after a response started streaming).override -
closeServer(
SecureServerSocket server) → Future< void> -
Also closes the connections still open, HTTP/2 and HTTP/1.
override
-
connectionsClosed(
) → Future< void> -
Ends each HTTP/2 connection once its streams are done (with a GOAWAY),
and waits for the HTTP/1 connections to close too.
override
-
createRequestContext(
Socket request, ServerTransportStream response) → Future< Http2RequestContext> -
override
-
createResponseContext(
Socket request, ServerTransportStream response, [Http2RequestContext? correspondingRequest]) → Future< Http2ResponseContext> -
override
-
createResponseStreamFromRawRequest(
Socket request) → Stream< ServerTransportStream> -
override
-
drain(
) → Future< void> -
Drains HTTP/1 requests too, which
allowHttp1serves. Calling it again returns the same future.override -
generateServer(
[Object? address, int? port]) → Future< SecureServerSocket> -
override
-
handleAngelHttpException(
AngelHttpException e, StackTrace st, RequestContext? req, ResponseContext? res, Socket request, ServerTransportStream response, {bool ignoreFinalizers = false}) → Future -
Handles an AngelHttpException.
inherited
-
handleRawRequest(
Socket request, ServerTransportStream response) → Future -
Handles a single request.
inherited
-
handleRawRequestSafely(
Socket request, ServerTransportStream 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
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
removeResponseHeader(
Map< String, Object?> headers) → void -
Removes default headers of the responses, by the rules of
AngelHttp.removeResponseHeader, including those that
dart:ioadds to the HTTP/1 ones. Like addResponseHeader, it may be called before startServer too. -
sendResponse(
Socket request, ServerTransportStream response, RequestContext req, ResponseContext res, {bool ignoreFinalizers = false}) → Future -
Sends a response.
override
-
setChunkedEncoding(
ServerTransportStream response, bool value) → void -
override
-
setContentLength(
ServerTransportStream response, int length) → void -
override
-
setHeader(
ServerTransportStream response, String key, String? value) → void -
override
-
setStatusCode(
ServerTransportStream response, int value) → void -
override
-
startServer(
[Object? address, int port = 0]) → Future< SecureServerSocket> -
Starts, and returns the server.
inherited
-
supportsChunkedEncoding(
Socket request) → bool -
Whether the client of
requestcan receive a chunked response; HTTP/1.0 clients cannot, so a driver for them overrides this.inherited -
toString(
) → String -
A string representation of this object.
inherited
-
writeStringToResponse(
ServerTransportStream response, String value) → void -
override
-
writeToResponse(
ServerTransportStream response, List< int> data) → void -
override
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited