Response class
The response returned by a Handler.
Constructors
-
Response(int statusCode, {Object? body, Map<
String, Object> ? headers, Encoding? encoding, Map<String, Object> ? context}) -
Constructs an HTTP response with the given
statusCode
. -
Response.badRequest({Object? body, Map<
String, Object> ? headers, Encoding? encoding, Map<String, Object> ? context}) - Constructs a 400 Bad Request response.
-
Response.forbidden(Object? body, {Map<
String, Object> ? headers, Encoding? encoding, Map<String, Object> ? context}) - Constructs a 403 Forbidden response.
-
Response.found(Object location, {Object? body, Map<
String, Object> ? headers, Encoding? encoding, Map<String, Object> ? context}) - Constructs a 302 Found response.
-
Response.internalServerError({Object? body, Map<
String, Object> ? headers, Encoding? encoding, Map<String, Object> ? context}) - Constructs a 500 Internal Server Error response.
-
Response.movedPermanently(Object location, {Object? body, Map<
String, Object> ? headers, Encoding? encoding, Map<String, Object> ? context}) - Constructs a 301 Moved Permanently response.
-
Response.notFound(Object? body, {Map<
String, Object> ? headers, Encoding? encoding, Map<String, Object> ? context}) - Constructs a 404 Not Found response.
-
Response.notModified({Map<
String, Object> ? headers, Map<String, Object> ? context}) - Constructs a 304 Not Modified response.
-
Response.ok(Object? body, {Map<
String, Object> ? headers, Encoding? encoding, Map<String, Object> ? context}) - Constructs a 200 OK response.
-
Response.seeOther(Object location, {Object? body, Map<
String, Object> ? headers, Encoding? encoding, Map<String, Object> ? context}) - Constructs a 303 See Other response.
- Constructs a 401 Unauthorized response.
Properties
- 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
- expires → DateTime?
-
The date and time after which the response's data should be considered
stale.
no setter
- 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
- isEmpty → bool
-
If
true
, the stream returned byread
won't emit any bytes.no setterinherited - lastModified → DateTime?
-
The date and time the source of the response's data was last modified.
no setter
- mimeType → String?
-
The MIME type of the message.
no setterinherited
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- statusCode → int
-
The HTTP status code of the response.
final
Methods
-
change(
{Map< String, Object?> ? headers, Map<String, Object?> ? context, Object? body}) → Response - Creates a new Response by copying existing values and applying specified changes.
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
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
-
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited