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

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

Issue 370743003: Add option to HttpClient to turn of auto uncompression (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Addressed review copmments Created 6 years, 5 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 | « sdk/lib/io/http.dart ('k') | tests/standalone/io/http_compression_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 252 matching lines...) Expand 10 before | Expand all | Expand 10 after
263 void onDone(), 263 void onDone(),
264 bool cancelOnError}) { 264 bool cancelOnError}) {
265 if (_incoming.upgraded) { 265 if (_incoming.upgraded) {
266 // If upgraded, the connection is already 'removed' form the client. 266 // If upgraded, the connection is already 'removed' form the client.
267 // Since listening to upgraded data is 'bogus', simply close and 267 // Since listening to upgraded data is 'bogus', simply close and
268 // return empty stream subscription. 268 // return empty stream subscription.
269 _httpRequest._httpClientConnection.destroy(); 269 _httpRequest._httpClientConnection.destroy();
270 return new Stream.fromIterable([]).listen(null, onDone: onDone); 270 return new Stream.fromIterable([]).listen(null, onDone: onDone);
271 } 271 }
272 var stream = _incoming; 272 var stream = _incoming;
273 if (headers.value(HttpHeaders.CONTENT_ENCODING) == "gzip") { 273 if (_httpClient.autoUncompress &&
274 headers.value(HttpHeaders.CONTENT_ENCODING) == "gzip") {
274 stream = stream.transform(GZIP.decoder); 275 stream = stream.transform(GZIP.decoder);
275 } 276 }
276 return stream.listen(onData, 277 return stream.listen(onData,
277 onError: onError, 278 onError: onError,
278 onDone: onDone, 279 onDone: onDone,
279 cancelOnError: cancelOnError); 280 cancelOnError: cancelOnError);
280 } 281 }
281 282
282 Future<Socket> detachSocket() { 283 Future<Socket> detachSocket() {
283 _httpClient._connectionClosed(_httpRequest._httpClientConnection); 284 _httpClient._connectionClosed(_httpRequest._httpClientConnection);
(...skipping 1359 matching lines...) Expand 10 before | Expand all | Expand 10 after
1643 Function _findProxy = HttpClient.findProxyFromEnvironment; 1644 Function _findProxy = HttpClient.findProxyFromEnvironment;
1644 Duration _idleTimeout = const Duration(seconds: 15); 1645 Duration _idleTimeout = const Duration(seconds: 15);
1645 Function _badCertificateCallback; 1646 Function _badCertificateCallback;
1646 1647
1647 Timer _noActiveTimer; 1648 Timer _noActiveTimer;
1648 1649
1649 Duration get idleTimeout => _idleTimeout; 1650 Duration get idleTimeout => _idleTimeout;
1650 1651
1651 int maxConnectionsPerHost; 1652 int maxConnectionsPerHost;
1652 1653
1654 bool autoUncompress = true;
1655
1653 String userAgent = _getHttpVersion(); 1656 String userAgent = _getHttpVersion();
1654 1657
1655 void set idleTimeout(Duration timeout) { 1658 void set idleTimeout(Duration timeout) {
1656 _idleTimeout = timeout; 1659 _idleTimeout = timeout;
1657 for (var c in _connectionTargets.values) { 1660 for (var c in _connectionTargets.values) {
1658 for (var idle in c.idle) { 1661 for (var idle in c.idle) {
1659 // Reset timer. This is fine, as it's not happening often. 1662 // Reset timer. This is fine, as it's not happening often.
1660 idle.stopTimer(); 1663 idle.stopTimer();
1661 idle.startTimer(); 1664 idle.startTimer();
1662 } 1665 }
(...skipping 1135 matching lines...) Expand 10 before | Expand all | Expand 10 after
2798 const _RedirectInfo(this.statusCode, this.method, this.location); 2801 const _RedirectInfo(this.statusCode, this.method, this.location);
2799 } 2802 }
2800 2803
2801 String _getHttpVersion() { 2804 String _getHttpVersion() {
2802 var version = Platform.version; 2805 var version = Platform.version;
2803 // Only include major and minor version numbers. 2806 // Only include major and minor version numbers.
2804 int index = version.indexOf('.', version.indexOf('.') + 1); 2807 int index = version.indexOf('.', version.indexOf('.') + 1);
2805 version = version.substring(0, index); 2808 version = version.substring(0, index);
2806 return 'Dart/$version (dart:io)'; 2809 return 'Dart/$version (dart:io)';
2807 } 2810 }
OLDNEW
« no previous file with comments | « sdk/lib/io/http.dart ('k') | tests/standalone/io/http_compression_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698