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

Side by Side Diff: sdk/lib/io/http_impl.dart

Issue 1128873011: Add handling of HTTP '100 Continue' intermediate response (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Addressed review comments Created 5 years, 7 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 | tests/standalone/io/http_100_continue.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) 2013, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2013, 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 part of dart.io; 5 part of dart.io;
6 6
7 const int _OUTGOING_BUFFER_SIZE = 8 * 1024; 7 const int _OUTGOING_BUFFER_SIZE = 8 * 1024;
8 8
9 class _HttpIncoming extends Stream<List<int>> { 9 class _HttpIncoming extends Stream<List<int>> {
10 final int _transferLength; 10 final int _transferLength;
(...skipping 1271 matching lines...) Expand 10 before | Expand all | Expand 10 after
1282 (incoming) { 1282 (incoming) {
1283 // Only handle one incoming response at the time. Keep the 1283 // Only handle one incoming response at the time. Keep the
1284 // stream paused until the response have been processed. 1284 // stream paused until the response have been processed.
1285 _subscription.pause(); 1285 _subscription.pause();
1286 // We assume the response is not here, until we have send the request. 1286 // We assume the response is not here, until we have send the request.
1287 if (_nextResponseCompleter == null) { 1287 if (_nextResponseCompleter == null) {
1288 throw new HttpException( 1288 throw new HttpException(
1289 "Unexpected response (unsolicited response without request).", 1289 "Unexpected response (unsolicited response without request).",
1290 uri: _currentUri); 1290 uri: _currentUri);
1291 } 1291 }
1292 _nextResponseCompleter.complete(incoming); 1292
1293 _nextResponseCompleter = null; 1293 // Check for status code '100 Continue'. In that case just
1294 // consume that response as the final response will follow
1295 // it. There is currently no API for the client to wait for
1296 // the '100 Continue' response.
1297 if (incoming.statusCode == 100) {
1298 incoming.drain().then((_) {
1299 _subscription.resume();
1300 }).catchError((error, [StackTrace stackTrace]) {
1301 _nextResponseCompleter.completeError(
1302 new HttpException(error.message, uri: _currentUri),
1303 stackTrace);
1304 _nextResponseCompleter = null;
1305 });
1306 } else {
1307 _nextResponseCompleter.complete(incoming);
1308 _nextResponseCompleter = null;
1309 }
1294 }, 1310 },
1295 onError: (error, [StackTrace stackTrace]) { 1311 onError: (error, [StackTrace stackTrace]) {
1296 if (_nextResponseCompleter != null) { 1312 if (_nextResponseCompleter != null) {
1297 _nextResponseCompleter.completeError( 1313 _nextResponseCompleter.completeError(
1298 new HttpException(error.message, uri: _currentUri), 1314 new HttpException(error.message, uri: _currentUri),
1299 stackTrace); 1315 stackTrace);
1300 _nextResponseCompleter = null; 1316 _nextResponseCompleter = null;
1301 } 1317 }
1302 }, 1318 },
1303 onDone: () { 1319 onDone: () {
(...skipping 1512 matching lines...) Expand 10 before | Expand all | Expand 10 after
2816 const _RedirectInfo(this.statusCode, this.method, this.location); 2832 const _RedirectInfo(this.statusCode, this.method, this.location);
2817 } 2833 }
2818 2834
2819 String _getHttpVersion() { 2835 String _getHttpVersion() {
2820 var version = Platform.version; 2836 var version = Platform.version;
2821 // Only include major and minor version numbers. 2837 // Only include major and minor version numbers.
2822 int index = version.indexOf('.', version.indexOf('.') + 1); 2838 int index = version.indexOf('.', version.indexOf('.') + 1);
2823 version = version.substring(0, index); 2839 version = version.substring(0, index);
2824 return 'Dart/$version (dart:io)'; 2840 return 'Dart/$version (dart:io)';
2825 } 2841 }
OLDNEW
« no previous file with comments | « no previous file | tests/standalone/io/http_100_continue.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698