OLD | NEW |
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 1262 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1273 | 1273 |
1274 // Set up handlers on the parser here, so we are sure to get 'onDone' from | 1274 // Set up handlers on the parser here, so we are sure to get 'onDone' from |
1275 // the parser. | 1275 // the parser. |
1276 _subscription = _httpParser.listen( | 1276 _subscription = _httpParser.listen( |
1277 (incoming) { | 1277 (incoming) { |
1278 // Only handle one incoming response at the time. Keep the | 1278 // Only handle one incoming response at the time. Keep the |
1279 // stream paused until the response have been processed. | 1279 // stream paused until the response have been processed. |
1280 _subscription.pause(); | 1280 _subscription.pause(); |
1281 // We assume the response is not here, until we have send the request. | 1281 // We assume the response is not here, until we have send the request. |
1282 if (_nextResponseCompleter == null) { | 1282 if (_nextResponseCompleter == null) { |
1283 throw new HttpException("Unexpected response.", uri: _currentUri); | 1283 throw new HttpException( |
| 1284 "Unexpected response (unsolicited response without request).", |
| 1285 uri: _currentUri); |
1284 } | 1286 } |
1285 _nextResponseCompleter.complete(incoming); | 1287 _nextResponseCompleter.complete(incoming); |
1286 _nextResponseCompleter = null; | 1288 _nextResponseCompleter = null; |
1287 }, | 1289 }, |
1288 onError: (error, [StackTrace stackTrace]) { | 1290 onError: (error, [StackTrace stackTrace]) { |
1289 if (_nextResponseCompleter != null) { | 1291 if (_nextResponseCompleter != null) { |
1290 _nextResponseCompleter.completeError( | 1292 _nextResponseCompleter.completeError( |
1291 new HttpException(error.message, uri: _currentUri), | 1293 new HttpException(error.message, uri: _currentUri), |
1292 stackTrace); | 1294 stackTrace); |
1293 _nextResponseCompleter = null; | 1295 _nextResponseCompleter = null; |
(...skipping 1507 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2801 const _RedirectInfo(this.statusCode, this.method, this.location); | 2803 const _RedirectInfo(this.statusCode, this.method, this.location); |
2802 } | 2804 } |
2803 | 2805 |
2804 String _getHttpVersion() { | 2806 String _getHttpVersion() { |
2805 var version = Platform.version; | 2807 var version = Platform.version; |
2806 // Only include major and minor version numbers. | 2808 // Only include major and minor version numbers. |
2807 int index = version.indexOf('.', version.indexOf('.') + 1); | 2809 int index = version.indexOf('.', version.indexOf('.') + 1); |
2808 version = version.substring(0, index); | 2810 version = version.substring(0, index); |
2809 return 'Dart/$version (dart:io)'; | 2811 return 'Dart/$version (dart:io)'; |
2810 } | 2812 } |
OLD | NEW |