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

Side by Side Diff: pkg/http/lib/src/base_request.dart

Issue 215533005: Fix a bug in [http.BaseRequest.send]'s content length handling. (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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | pkg/http/test/streamed_request_test.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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_request; 5 library base_request;
6 6
7 import 'dart:async'; 7 import 'dart:async';
8 import 'dart:collection'; 8 import 'dart:collection';
9 9
10 import 'byte_stream.dart'; 10 import 'byte_stream.dart';
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after
108 /// Sends this request. 108 /// Sends this request.
109 /// 109 ///
110 /// This automatically initializes a new [Client] and closes that client once 110 /// This automatically initializes a new [Client] and closes that client once
111 /// the request is complete. If you're planning on making multiple requests to 111 /// the request is complete. If you're planning on making multiple requests to
112 /// the same server, you should use a single [Client] for all of those 112 /// the same server, you should use a single [Client] for all of those
113 /// requests. 113 /// requests.
114 Future<StreamedResponse> send() { 114 Future<StreamedResponse> send() {
115 var client = new Client(); 115 var client = new Client();
116 return client.send(this).then((response) { 116 return client.send(this).then((response) {
117 var stream = onDone(response.stream, client.close); 117 var stream = onDone(response.stream, client.close);
118 var contentLength = response.contentLength < 0 ?
119 null : response.contentLength;
120 return new StreamedResponse( 118 return new StreamedResponse(
121 new ByteStream(stream), 119 new ByteStream(stream),
122 response.statusCode, 120 response.statusCode,
123 contentLength: contentLength, 121 contentLength: response.contentLength,
124 request: response.request, 122 request: response.request,
125 headers: response.headers, 123 headers: response.headers,
126 isRedirect: response.isRedirect, 124 isRedirect: response.isRedirect,
127 persistentConnection: response.persistentConnection, 125 persistentConnection: response.persistentConnection,
128 reasonPhrase: response.reasonPhrase); 126 reasonPhrase: response.reasonPhrase);
129 }).catchError((e) { 127 }).catchError((e) {
130 client.close(); 128 client.close();
131 throw e; 129 throw e;
132 }); 130 });
133 } 131 }
134 132
135 // Throws an error if this request has been finalized. 133 // Throws an error if this request has been finalized.
136 void _checkFinalized() { 134 void _checkFinalized() {
137 if (!finalized) return; 135 if (!finalized) return;
138 throw new StateError("Can't modify a finalized Request."); 136 throw new StateError("Can't modify a finalized Request.");
139 } 137 }
140 138
141 String toString() => "$method $url"; 139 String toString() => "$method $url";
142 } 140 }
OLDNEW
« no previous file with comments | « no previous file | pkg/http/test/streamed_request_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698