Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(423)

Unified Diff: pkg/http/lib/src/base_response.dart

Issue 196423017: Make BaseRequest.contentType use null rather than -1 as a flag value. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: code review Created 6 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « pkg/http/lib/src/base_request.dart ('k') | pkg/http/lib/src/io_client.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/http/lib/src/base_response.dart
diff --git a/pkg/http/lib/src/base_response.dart b/pkg/http/lib/src/base_response.dart
index df0edb4e34c4dcb4b5e9ef15ae6a2c2214e0c95b..f2225962eb3ac58ee4f7dac7f336d5a853987268 100644
--- a/pkg/http/lib/src/base_response.dart
+++ b/pkg/http/lib/src/base_response.dart
@@ -20,8 +20,9 @@ abstract class BaseResponse {
/// The reason phrase associated with the status code.
final String reasonPhrase;
- /// The size of the response body, in bytes. If the size of the request is not
- /// known in advance, this is -1.
+ /// The size of the response body, in bytes.
+ ///
+ /// If the size of the request is not known in advance, this is `null`.
final int contentLength;
// TODO(nweiz): automatically parse cookies from headers
@@ -39,10 +40,16 @@ abstract class BaseResponse {
/// Creates a new HTTP response.
BaseResponse(
this.statusCode,
- this.contentLength,
- {this.request,
+ {this.contentLength,
+ this.request,
this.headers: const {},
this.isRedirect: false,
this.persistentConnection: true,
- this.reasonPhrase});
+ this.reasonPhrase}) {
+ if (statusCode < 100) {
+ throw new ArgumentError("Invalid status code $statusCode.");
+ } else if (contentLength != null && contentLength < 0) {
+ throw new ArgumentError("Invalid content length $contentLength.");
+ }
+ }
}
« no previous file with comments | « pkg/http/lib/src/base_request.dart ('k') | pkg/http/lib/src/io_client.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698