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

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: 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/pubspec.yaml » ('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..e50449a6ddcc9a04c2f52269038410b125ecdd53 100644
--- a/pkg/http/lib/src/base_request.dart
+++ b/pkg/http/lib/src/base_request.dart
@@ -27,12 +27,15 @@ 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
Bob Nystrom 2014/03/17 17:59:19 Why this change? I think most users expect ints t
nweiz 2014/03/17 19:36:01 [String.indexOf] is a holdover from JavaScript whi
Bob Nystrom 2014/03/17 21:08:45 Sure, and millions of people know and expect that
nweiz 2014/03/17 21:25:09 Every JavaScript developer expects objects to be m
kevmoo 2014/03/17 21:30:53 I agree with this logic. For helpers accessing th
Bob Nystrom 2014/03/17 21:32:05 Sure, and Dart was designed expressly to not surpr
nweiz 2014/03/17 21:57:48 Dart was designed in the tradition of Java and Jav
+ /// not known in advance.
int get contentLength => _contentLength;
- int _contentLength = -1;
+ int _contentLength;
set contentLength(int value) {
+ if (value < 0) throw new ArgumentError("Invalid content length $value.");
kevmoo 2014/03/17 17:53:25 Is setting null valid here? Will the `<` blow up o
nweiz 2014/03/17 19:36:01 Good catch. Done.
_checkFinalized();
_contentLength = value;
}
@@ -113,7 +116,7 @@ abstract class BaseRequest {
return new StreamedResponse(
new ByteStream(stream),
response.statusCode,
- response.contentLength,
+ response.contentLength == null ? -1 : response.contentLength,
request: response.request,
headers: response.headers,
isRedirect: response.isRedirect,
« no previous file with comments | « pkg/http/CHANGELOG.md ('k') | pkg/http/pubspec.yaml » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698