Request class
Represents an HTTP request and provides various utilities to access request data and metadata.
Constructors
-
Request(HttpRequest _httpRequest, Map<
String, dynamic> pathParameters, EngineConfig config) - Constructs a Request object.
-
Request.fromAdapter(RequestAdapter adapter, Map<
String, dynamic> pathParameters, EngineConfig config) -
Constructs a portable Request from a host adapter.
factory
Properties
- bodyConsumed → bool
-
Returns whether the request body has been consumed.
no setter
-
bytes
→ Future<
Uint8List> -
Returns the body of the request as bytes.
no setter
- certificate → X509Certificate?
-
Returns the client certificate of the client making the request.
no setter
- clientIP → String
-
Returns the IP address of the client making the request.
no setter
- config ↔ EngineConfig
-
The engine configuration used while processing this request.
getter/setter pair
- connectionInfo → HttpConnectionInfo?
-
Information about the client connection.
no setter
- contentLength → int
-
Returns the content length of the request body.
no setter
- contentType → ContentType?
-
Returns the content type of the request, if available.
no setter
-
Returns the cookies sent with the request.
no setter
- hasBody → bool
-
Returns whether the request has a body.
no setter
- hashCode → int
-
The hash code for this object.
no setterinherited
- hasNativeHttpRequest → bool
-
Whether this request is backed by a real native
dart:iorequest.no setter - headers → HttpHeaders
-
Returns the headers of the request.
no setter
- host → String
-
Returns the host of the request.
no setter
- hostContext → Object?
-
Opaque host context supplied by a portable request adapter, when any.
no setter
- httpRequest → HttpRequest
-
The underlying native HttpRequest object.
no setter
- id → String
-
A unique identifier for the request.
final
- identity → Request
-
Stable object identity used by request-scoped
Expandostorage.no setter - isPortable → bool
-
Whether this request was built from a portable adapter.
no setter
- method → String
-
Returns the HTTP method of the request (e.g., GET, POST).
no setter
- path → String
-
Returns the path of the request URI.
no setter
-
pathParameters
→ Map<
String, dynamic> -
A map of path parameters extracted from the request URI.
final
- persistentConnection → bool
-
Returns the persistent connection state signaled by the client.
no setter
- protocolVersion → String
-
Returns the HTTP protocol version used in the request, either "1.0" or "1.1".
no setter
-
queryParameters
→ Map<
String, String> -
A map of query parameters extracted from the request URI.
final
- remoteAddr → String
-
Returns the remote address of the client making the request.
no setter
- requestedUri → Uri
-
Returns the requested URI for the request.
no setter
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- scheme → String
-
Returns the scheme of the request URI (e.g., http, https).
no setter
- session → HttpSession
-
Returns the session for the given request.
no setter
- startedAt → DateTime
-
Timestamp indicating when the request handling began.
final
-
stream
→ Stream<
List< int> > -
Returns a stream of the request body data.
no setter
- uri → Uri
-
Returns the URI of the request.
no setter
Methods
-
body(
) → FutureOr< String> - Returns the body of the request as a UTF-8 decoded string.
-
clearAttributes(
) → void - Clears all request-scoped attributes.
-
containsAttribute(
String key) → bool -
Returns
trueif an attribute withkeyis present, even when its value isnull(e.g. written via setAttribute). -
drain(
) → Future< void> - Drain the request body to allow keep-alive reuse when handlers don't read it. Safe to call multiple times.
-
getAttribute<
T> (String key) → T? -
Retrieves a request-scoped attribute by
key. -
header(
String name) → String -
Returns the value of the specified header
name. -
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
overrideClientIp(
String ip) → void - Creates a Request.
-
setAttribute(
String key, dynamic value) → void -
Sets a request-scoped attribute with the given
keyandvalue. Store a valuevalueunderkey. -
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited