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

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

Issue 308923002: When a connection is upgraded, don't return it as idle. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 6 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_detach_socket_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) 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 244 matching lines...) Expand 10 before | Expand all | Expand 10 after
255 ..addAll(this.redirects) 255 ..addAll(this.redirects)
256 ..add(new _RedirectInfo(statusCode, method, url)); 256 ..add(new _RedirectInfo(statusCode, method, url));
257 return request.close(); 257 return request.close();
258 }); 258 });
259 } 259 }
260 260
261 StreamSubscription<List<int>> listen(void onData(List<int> event), 261 StreamSubscription<List<int>> listen(void onData(List<int> event),
262 {Function onError, 262 {Function onError,
263 void onDone(), 263 void onDone(),
264 bool cancelOnError}) { 264 bool cancelOnError}) {
265 if (_incoming.upgraded) {
266 // If upgraded, the connection is already 'removed' form the client.
267 // Since listening to upgraded data is 'bogus', simply close and
268 // return empty stream subscription.
269 _httpRequest._httpClientConnection.destroy();
270 return new Stream.fromIterable([]).listen(null, onDone: onDone);
271 }
265 var stream = _incoming; 272 var stream = _incoming;
266 if (headers.value(HttpHeaders.CONTENT_ENCODING) == "gzip") { 273 if (headers.value(HttpHeaders.CONTENT_ENCODING) == "gzip") {
267 stream = stream.transform(GZIP.decoder); 274 stream = stream.transform(GZIP.decoder);
268 } 275 }
269 return stream.listen(onData, 276 return stream.listen(onData,
270 onError: onError, 277 onError: onError,
271 onDone: onDone, 278 onDone: onDone,
272 cancelOnError: cancelOnError); 279 cancelOnError: cancelOnError);
273 } 280 }
274 281
(...skipping 1077 matching lines...) Expand 10 before | Expand all | Expand 10 after
1352 _streamFuture = outgoing.done 1359 _streamFuture = outgoing.done
1353 .then((s) { 1360 .then((s) {
1354 // Request sent, set up response completer. 1361 // Request sent, set up response completer.
1355 _nextResponseCompleter = new Completer(); 1362 _nextResponseCompleter = new Completer();
1356 1363
1357 // Listen for response. 1364 // Listen for response.
1358 _nextResponseCompleter.future 1365 _nextResponseCompleter.future
1359 .then((incoming) { 1366 .then((incoming) {
1360 _currentUri = null; 1367 _currentUri = null;
1361 incoming.dataDone.then((closing) { 1368 incoming.dataDone.then((closing) {
1369 if (incoming.upgraded) {
1370 _httpClient._connectionClosed(this);
1371 startTimer();
1372 return;
1373 }
1362 if (closed) return; 1374 if (closed) return;
1363 if (!closing && 1375 if (!closing &&
1364 !_dispose && 1376 !_dispose &&
1365 incoming.headers.persistentConnection && 1377 incoming.headers.persistentConnection &&
1366 request.persistentConnection) { 1378 request.persistentConnection) {
1367 // Return connection, now we are done. 1379 // Return connection, now we are done.
1368 _httpClient._returnConnection(this); 1380 _httpClient._returnConnection(this);
1369 _subscription.resume(); 1381 _subscription.resume();
1370 } else { 1382 } else {
1371 destroy(); 1383 destroy();
(...skipping 1344 matching lines...) Expand 10 before | Expand all | Expand 10 after
2716 const _RedirectInfo(this.statusCode, this.method, this.location); 2728 const _RedirectInfo(this.statusCode, this.method, this.location);
2717 } 2729 }
2718 2730
2719 String _getHttpVersion() { 2731 String _getHttpVersion() {
2720 var version = Platform.version; 2732 var version = Platform.version;
2721 // Only include major and minor version numbers. 2733 // Only include major and minor version numbers.
2722 int index = version.indexOf('.', version.indexOf('.') + 1); 2734 int index = version.indexOf('.', version.indexOf('.') + 1);
2723 version = version.substring(0, index); 2735 version = version.substring(0, index);
2724 return 'Dart/$version (dart:io)'; 2736 return 'Dart/$version (dart:io)';
2725 } 2737 }
OLDNEW
« no previous file with comments | « no previous file | tests/standalone/io/http_detach_socket_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698