Index: pkg/shelf/lib/src/response.dart |
diff --git a/pkg/shelf/lib/src/response.dart b/pkg/shelf/lib/src/response.dart |
index bbc268bed4f7f8a8e9e7e35f8c8559eb3a97bf65..e59b0c55ef8482ebee3c0d758aa1ec496473fe2e 100644 |
--- a/pkg/shelf/lib/src/response.dart |
+++ b/pkg/shelf/lib/src/response.dart |
@@ -53,8 +53,10 @@ class Response extends Message { |
/// If [encoding] is passed, the "encoding" field of the Content-Type header |
/// in [headers] will be set appropriately. If there is no existing |
/// Content-Type header, it will be set to "application/octet-stream". |
- Response.ok(body, {Map<String, String> headers, Encoding encoding}) |
- : this(200, body: body, headers: headers, encoding: encoding); |
+ Response.ok(body, {Map<String, String> headers, Encoding encoding, |
+ Map<String, Object> context}) |
+ : this(200, body: body, headers: headers, encoding: encoding, |
+ context: context); |
/// Constructs a 301 Moved Permanently response. |
/// |
@@ -71,8 +73,9 @@ class Response extends Message { |
/// in [headers] will be set appropriately. If there is no existing |
/// Content-Type header, it will be set to "application/octet-stream". |
Response.movedPermanently(location, {body, Map<String, String> headers, |
- Encoding encoding}) |
- : this._redirect(301, location, body, headers, encoding); |
+ Encoding encoding, Map<String, Object> context}) |
+ : this._redirect(301, location, body, headers, encoding, |
+ context: context); |
/// Constructs a 302 Found response. |
/// |
@@ -89,8 +92,9 @@ class Response extends Message { |
/// in [headers] will be set appropriately. If there is no existing |
/// Content-Type header, it will be set to "application/octet-stream". |
Response.found(location, {body, Map<String, String> headers, |
- Encoding encoding}) |
- : this._redirect(302, location, body, headers, encoding); |
+ Encoding encoding, Map<String, Object> context}) |
+ : this._redirect(302, location, body, headers, encoding, |
+ context: context); |
/// Constructs a 303 See Other response. |
/// |
@@ -108,17 +112,20 @@ class Response extends Message { |
/// in [headers] will be set appropriately. If there is no existing |
/// Content-Type header, it will be set to "application/octet-stream". |
Response.seeOther(location, {body, Map<String, String> headers, |
- Encoding encoding}) |
- : this._redirect(303, location, body, headers, encoding); |
+ Encoding encoding, Map<String, Object> context}) |
+ : this._redirect(303, location, body, headers, encoding, |
+ context: context); |
/// Constructs a helper constructor for redirect responses. |
Response._redirect(int statusCode, location, body, |
- Map<String, String> headers, Encoding encoding) |
+ Map<String, String> headers, Encoding encoding, |
+ { Map<String, Object> context }) |
: this(statusCode, |
body: body, |
encoding: encoding, |
headers: _addHeader( |
- headers, 'location', _locationToString(location))); |
+ headers, 'location', _locationToString(location)), |
+ context: context); |
/// Constructs a 304 Not Modified response. |
/// |
@@ -126,9 +133,11 @@ class Response extends Message { |
/// information used to determine whether the requested resource has changed |
/// since the last request. It indicates that the resource has not changed and |
/// the old value should be used. |
- Response.notModified({Map<String, String> headers}) |
+ Response.notModified({Map<String, String> headers, |
+ Map<String, Object> context}) |
: this(304, headers: _addHeader( |
- headers, 'date', formatHttpDate(new DateTime.now()))); |
+ headers, 'date', formatHttpDate(new DateTime.now())), |
+ context: context); |
/// Constructs a 403 Forbidden response. |
/// |
@@ -143,8 +152,9 @@ class Response extends Message { |
/// in [headers] will be set appropriately. If there is no existing |
/// Content-Type header, it will be set to "application/octet-stream". |
Response.forbidden(body, {Map<String, String> headers, |
- Encoding encoding}) |
- : this(403, body: body, headers: headers); |
+ Encoding encoding, Map<String, Object> context}) |
+ : this(403, body: body, headers: headers, |
+ context: context); |
/// Constructs a 404 Not Found response. |
/// |
@@ -159,8 +169,10 @@ class Response extends Message { |
/// If [encoding] is passed, the "encoding" field of the Content-Type header |
/// in [headers] will be set appropriately. If there is no existing |
/// Content-Type header, it will be set to "application/octet-stream". |
- Response.notFound(body, {Map<String, String> headers, Encoding encoding}) |
- : this(404, body: body, headers: headers); |
+ Response.notFound(body, {Map<String, String> headers, Encoding encoding, |
+ Map<String, Object> context}) |
+ : this(404, body: body, headers: headers, |
+ context: context); |
/// Constructs a 500 Internal Server Error response. |
/// |
@@ -176,10 +188,11 @@ class Response extends Message { |
/// in [headers] will be set appropriately. If there is no existing |
/// Content-Type header, it will be set to "application/octet-stream". |
Response.internalServerError({body, Map<String, String> headers, |
- Encoding encoding}) |
+ Encoding encoding, Map<String, Object> context}) |
: this(500, |
headers: body == null ? _adjust500Headers(headers) : headers, |
- body: body == null ? 'Internal Server Error' : body); |
+ body: body == null ? 'Internal Server Error' : body, |
+ context: context); |
/// Constructs an HTTP response with the given [statusCode]. |
/// |
@@ -194,9 +207,10 @@ class Response extends Message { |
/// in [headers] will be set appropriately. If there is no existing |
/// Content-Type header, it will be set to "application/octet-stream". |
Response(this.statusCode, {body, Map<String, String> headers, |
- Encoding encoding}) |
+ Encoding encoding, Map<String, Object> context}) |
: super(_bodyToStream(body, encoding), |
- headers: _adjustHeaders(headers, encoding)) { |
+ headers: _adjustHeaders(headers, encoding), |
+ context: context) { |
if (statusCode < 100) { |
throw new ArgumentError("Invalid status code: $statusCode."); |
} |