Skip to content

Commit 92b37ee

Browse files
committed
Adding back missing Response fields
1 parent e9dbebd commit 92b37ee

File tree

1 file changed

+30
-7
lines changed

1 file changed

+30
-7
lines changed

lib/src/response.dart

Lines changed: 30 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,20 @@ import 'utils.dart';
1111

1212
/// An HTTP response where the entire response body is known in advance.
1313
class Response extends Message {
14+
/// The location of the requested resource.
15+
///
16+
/// The value takes into account any redirects that occurred during the
17+
/// request.
18+
final Uri location;
19+
1420
/// The status code of the response.
1521
final int statusCode;
1622

17-
/// Creates a new HTTP response with the given [statusCode].
23+
/// The reason phrase associated with the status code.
24+
final String reasonPhrase;
25+
26+
/// Creates a new HTTP response for a resource at the [location], which can
27+
/// be a [Uri] or a [String], with the given [statusCode].
1828
///
1929
/// [body] is the request body. It may be either a [String], a [List<int>], a
2030
/// [Stream<List<int>>], or `null` to indicate no body. If it's a [String],
@@ -26,11 +36,20 @@ class Response extends Message {
2636
///
2737
/// Extra [context] can be used to pass information between outer middleware
2838
/// and handlers.
29-
Response(this.statusCode,
30-
{body,
39+
Response(location, int statusCode,
40+
{String reasonPhrase,
41+
body,
3142
Encoding encoding,
3243
Map<String, String> headers,
3344
Map<String, Object> context})
45+
: this._(getUrl(location), statusCode, reasonPhrase ?? '',
46+
body, encoding, headers, context);
47+
48+
Response._(this.location, this.statusCode, this.reasonPhrase,
49+
body,
50+
Encoding encoding,
51+
Map<String, String> headers,
52+
Map<String, Object> context)
3453
: super(body, encoding: encoding, headers: headers, context: context);
3554

3655
/// Creates a new [Response] by copying existing values and applying specified
@@ -55,10 +74,14 @@ class Response extends Message {
5574
var updatedHeaders = updateMap(this.headers, headers);
5675
var updatedContext = updateMap(this.context, context);
5776

58-
return new Response(this.statusCode,
59-
body: body ?? getBody(this),
60-
headers: updatedHeaders,
61-
context: updatedContext);
77+
return new Response._(
78+
this.location,
79+
this.statusCode,
80+
this.reasonPhrase,
81+
body ?? getBody(this),
82+
this.encoding,
83+
updatedHeaders,
84+
updatedContext);
6285
}
6386

6487
/// The date and time after which the response's data should be considered

0 commit comments

Comments
 (0)