HubRequest class

A protocol-agnostic inbound request.

Wraps the essentials of an HTTP request (or a WebSocket upgrade request) without exposing the underlying shelf/dart:io types, so services and routing rules never depend on a particular server implementation. Transports build these; the pipeline enriches them (e.g. attaching a principal); the router matches on them; services consume them.

Constructors

HubRequest({required String method, required Uri uri, required TransportProtocol protocol, Map<String, String> headers = const {}, Stream<List<int>>? body, String? remoteAddress, Principal? principal})
Creates a request. headers keys are lower-cased. body defaults to an empty stream.

Properties

context Map<String, Object?>
A scratch space for middleware/services to stash per-request data.
final
hashCode int
The hash code for this object.
no setterinherited
headers Map<String, String>
Request headers, with lower-cased keys.
final
host String
The host component of the URI (no port).
no setter
isSecure bool
Whether the request arrived over TLS.
no setter
isWebSocketUpgrade bool
Whether this is a WebSocket upgrade request (Upgrade: websocket).
no setter
method String
The HTTP method, upper-cased (GET, POST, ...).
final
path String
The request path (no query string).
no setter
principal Principal?
The authenticated identity, or null if anonymous. Set by the authentication stage of the pipeline.
getter/setter pair
protocol → TransportProtocol
The protocol this request arrived on.
final
remoteAddress String?
The remote peer address, if known (e.g. 203.0.113.4).
final
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
uri Uri
The full requested URI, including scheme, host and query.
final

Methods

The value of header name (case-insensitive), or null.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
read() Stream<List<int>>
The request body as a byte stream. May only be consumed once.
readAsString([Encoding encoding = utf8]) Future<String>
Buffers and decodes the entire request body as a string (utf8 default).
readBytes() Future<List<int>>
Buffers and returns the entire request body as bytes.
toString() String
A string representation of this object.
override

Operators

operator ==(Object other) bool
The equality operator.
inherited