Chromium Code Reviews| 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, |