OLD | NEW |
---|---|
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file |
2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
4 | 4 |
5 library base_response; | 5 library base_response; |
6 | 6 |
7 import 'dart:io'; | 7 import 'dart:io'; |
8 | 8 |
9 import 'base_request.dart'; | |
10 | |
9 /// The base class for HTTP responses. | 11 /// The base class for HTTP responses. |
10 /// | 12 /// |
11 /// Subclasses of [BaseResponse] are usually not constructed manually; instead, | 13 /// Subclasses of [BaseResponse] are usually not constructed manually; instead, |
12 /// they're returned by [BaseClient.send] or other HTTP client methods. | 14 /// they're returned by [BaseClient.send] or other HTTP client methods. |
13 abstract class BaseResponse { | 15 abstract class BaseResponse { |
16 /// The (frozen) request that triggered this response. | |
17 final BaseRequest request; | |
Bob Nystrom
2012/11/29 23:57:04
Pedantic, but you should have a test that you can
nweiz
2012/11/30 00:08:54
Done.
| |
18 | |
14 /// The status code of the response. | 19 /// The status code of the response. |
15 final int statusCode; | 20 final int statusCode; |
16 | 21 |
17 /// The reason phrase associated with the status code. | 22 /// The reason phrase associated with the status code. |
18 final String reasonPhrase; | 23 final String reasonPhrase; |
19 | 24 |
20 /// The size of the response body, in bytes. If the size of the request is not | 25 /// The size of the response body, in bytes. If the size of the request is not |
21 /// known in advance, this is -1. | 26 /// known in advance, this is -1. |
22 final int contentLength; | 27 final int contentLength; |
23 | 28 |
24 // TODO(nweiz): automatically parse cookies from headers | 29 // TODO(nweiz): automatically parse cookies from headers |
25 | 30 |
26 // TODO(nweiz): make this a HttpHeaders object. | 31 // TODO(nweiz): make this a HttpHeaders object. |
27 /// The headers for this response. | 32 /// The headers for this response. |
28 final Map<String, String> headers; | 33 final Map<String, String> headers; |
29 | 34 |
30 /// Whether this response is a redirect. | 35 /// Whether this response is a redirect. |
31 final bool isRedirect; | 36 final bool isRedirect; |
32 | 37 |
33 /// Whether the server requested that a persistent connection be maintained. | 38 /// Whether the server requested that a persistent connection be maintained. |
34 final bool persistentConnection; | 39 final bool persistentConnection; |
35 | 40 |
36 /// Creates a new HTTP response. | 41 /// Creates a new HTTP response. |
37 BaseResponse( | 42 BaseResponse( |
38 this.statusCode, | 43 this.statusCode, |
39 this.contentLength, | 44 this.contentLength, |
40 {this.headers: const <String>{}, | 45 {this.request, |
46 this.headers: const <String>{}, | |
41 this.isRedirect: false, | 47 this.isRedirect: false, |
42 this.persistentConnection: true, | 48 this.persistentConnection: true, |
43 this.reasonPhrase}); | 49 this.reasonPhrase}); |
44 } | 50 } |
OLD | NEW |