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

Unified Diff: pkg/http/lib/src/base_request.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/CHANGELOG.md ('k') | pkg/http/lib/src/base_response.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/http/lib/src/base_request.dart
diff --git a/pkg/http/lib/src/base_request.dart b/pkg/http/lib/src/base_request.dart
index dab055b4e096ecf07e927a9c1629dcd0713fdf94..a52b9c27b6aafe106a12b591b44ecf7d35ff5a35 100644
--- a/pkg/http/lib/src/base_request.dart
+++ b/pkg/http/lib/src/base_request.dart
@@ -27,12 +27,17 @@ abstract class BaseRequest {
/// The URL to which the request will be sent.
final Uri url;
- /// The size of the request body, in bytes. This defaults to -1, which
- /// indicates that the size of the request is not known in advance.
+ /// The size of the request body, in bytes.
+ ///
+ /// This defaults to `null`, which indicates that the size of the request is
+ /// not known in advance.
int get contentLength => _contentLength;
- int _contentLength = -1;
+ int _contentLength;
set contentLength(int value) {
+ if (value != null && value < 0) {
+ throw new ArgumentError("Invalid content length $value.");
+ }
_checkFinalized();
_contentLength = value;
}
@@ -110,10 +115,12 @@ abstract class BaseRequest {
var client = new Client();
return client.send(this).then((response) {
var stream = onDone(response.stream, client.close);
+ var contentLength = response.contentLength < 0 ?
+ null : response.contentLength;
return new StreamedResponse(
new ByteStream(stream),
response.statusCode,
- response.contentLength,
+ contentLength: contentLength,
request: response.request,
headers: response.headers,
isRedirect: response.isRedirect,
« no previous file with comments | « pkg/http/CHANGELOG.md ('k') | pkg/http/lib/src/base_response.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698