Request class
An HTTP request to be processed by a Shelf application.
- Available extensions
Constructors
Properties
- canHijack → bool
-
Whether this request can be hijacked.
no setter
- contentLength → int?
-
The contents of the content-length field in
headers.no setterinherited -
context
→ Map<
String, Object> -
Extra context that can be used by for middleware and handlers.
finalinherited
- encoding → Encoding?
-
The encoding of the message body.
no setterinherited
- handlerPath → String
-
The URL path to the current handler.
final
- hashCode → int
-
The hash code for this object.
no setterinherited
-
headers
→ Map<
String, String> -
The HTTP headers with case-insensitive keys.
no setterinherited
-
headersAll
→ Map<
String, List< String> > -
The HTTP headers with multiple values with case-insensitive keys.
no setterinherited
- ifModifiedSince → DateTime?
-
If this is non-
nulland the requested resource hasn't been modified since this date and time, the server should return a 304 Not Modified response.no setter - isEmpty → bool
-
If
true, the stream returned byreadwon't emit any bytes.no setterinherited - method → String
-
The HTTP request method, such as "GET" or "POST".
final
- mimeType → String?
-
The MIME type of the message.
no setterinherited
- protocolVersion → String
-
The HTTP protocol version used in the request, either "1.0" or "1.1".
final
- requestedUri → Uri
-
The original Uri for the request.
final
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- url → Uri
-
The URL path from the current handler to the requested resource, relative
to handlerPath, plus any query parameters.
final
Methods
-
apiKey(
{String header = 'x-api-key', String query = 'api_key', bool allowQuery = true}) → Future< String> -
Available on Request, provided by the RequestExtraction extension
An API key from a header, falling back to the query string. -
basicCredentials(
{String realm = 'restricted'}) → Future< BasicCredentials> -
Available on Request, provided by the RequestExtraction extension
The decoded username and password of anAuthorization: Basicheader. -
bearerToken(
) → Future< String> -
Available on Request, provided by the RequestExtraction extension
The token from anAuthorization: Bearerheader. -
body<
T> (T deserialize(Map< String, Object?> json)) → Future<T> -
Available on Request, provided by the RequestExtraction extension
The JSON object body, decoded withdeserialize. -
bodyList<
T> (T deserialize(Map< String, Object?> json)) → Future<List< T> > -
Available on Request, provided by the RequestExtraction extension
The JSON array body, each element decoded withdeserialize. -
bodyStream(
) → Future< Stream< List< >int> > -
Available on Request, provided by the RequestExtraction extension
The body as an unread stream, for a handler that owns its own limit. -
change(
{Map< String, Object?> ? headers, Map<String, Object?> ? context, String? path, Object? body}) → Request - Creates a new Request by copying existing values and applying specified changes.
-
Available on Request, provided by the RequestExtraction extension
One cookie, coerced toT. A nullableTmakes it optional. -
Available on Request, provided by the RequestExtraction extension
Every cookie at once. -
extract<
T> (FromRequestParts< T> extractor) → Future<T> -
Available on Request, provided by the RequestExtraction extension
Runsextractoragainst this request. -
form(
) → Future< FormMap> -
Available on Request, provided by the RequestExtraction extension
The decoded fields of anapplication/x-www-form-urlencodedbody. -
header(
String name) → Future< String?> -
Available on Request, provided by the RequestExtraction extension
One header, ornullwhen it is absent. -
headerMap(
) → Future< Map< String, String> > -
Available on Request, provided by the RequestExtraction extension
Every header at once, keyed by lower-case name. -
hijack(
void callback(StreamChannel< List< )) → Neverint> > - Takes control of the underlying request socket.
-
host(
) → Future< String> -
Available on Request, provided by the RequestExtraction extension
TheHostheader this request was addressed to. -
multipart(
) → Future< MultipartForm> -
Available on Request, provided by the RequestExtraction extension
The parts of amultipart/form-databody. -
multipartStream(
{int limit = 64 * 1024 * 1024}) → Future< StreamedMultipart> -
Available on Request, provided by the RequestExtraction extension
Hands the multipart body over a part at a time, without buffering it. -
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
path<
T> (String name) → Future< T> -
Available on Request, provided by the RequestExtraction extension
The{name}path segment, coerced toT. -
peer(
) → Future< PeerInfo> -
Available on Request, provided by the RequestExtraction extension
The connection's peer address and port. -
queries(
) → Future< Map< String, String> > -
Available on Request, provided by the RequestExtraction extension
Every query pair at once. -
query<
T> (String name) → Future< T> -
Available on Request, provided by the RequestExtraction extension
One query value, coerced toT. -
queryList<
T> (String name) → Future< List< T> > -
Available on Request, provided by the RequestExtraction extension
Every value of a repeated query key, coerced toT. -
rawBody(
) → Future< Uint8List> -
Available on Request, provided by the RequestExtraction extension
The body as raw bytes. -
rawQuery(
) → Future< String?> -
Available on Request, provided by the RequestExtraction extension
The raw, undecoded query string, ornullwhen there is none. -
read(
) → Stream< List< int> > -
Returns a Stream representing the body.
inherited
-
readAsString(
[Encoding? encoding]) → Future< String> -
Returns a Future containing the body as a String.
inherited
-
sessionId(
{String name = 'session'}) → Future< String> -
Available on Request, provided by the RequestExtraction extension
A session identifier from a cookie, as 401 rather than 400 when absent. -
state<
T extends Object> () → Future< T> -
Available on Request, provided by the RequestExtraction extension
The application state of typeTattached withwithState. -
textBody(
) → Future< String> -
Available on Request, provided by the RequestExtraction extension
The body as UTF-8 text. -
toString(
) → String -
A string representation of this object.
inherited
-
validBody<
T extends Validatable> (T deserialize(Map< String, Object?> json)) → Future<T> -
Available on Request, provided by the RequestExtraction extension
The JSON object body, decoded and then checked against its constraints.
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited