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

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

Issue 22867033: Update ZLib/GZip in dart:io to be a Codec/Converter from dart:convert. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Add documentation and convert impl. Created 7 years, 4 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
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 class _HttpIncoming extends Stream<List<int>> { 7 class _HttpIncoming extends Stream<List<int>> {
8 final int _transferLength; 8 final int _transferLength;
9 final Completer _dataCompleter = new Completer(); 9 final Completer _dataCompleter = new Completer();
10 Stream<List<int>> _stream; 10 Stream<List<int>> _stream;
(...skipping 225 matching lines...) Expand 10 before | Expand all | Expand 10 after
236 return request.close(); 236 return request.close();
237 }); 237 });
238 } 238 }
239 239
240 StreamSubscription<List<int>> listen(void onData(List<int> event), 240 StreamSubscription<List<int>> listen(void onData(List<int> event),
241 {void onError(error), 241 {void onError(error),
242 void onDone(), 242 void onDone(),
243 bool cancelOnError}) { 243 bool cancelOnError}) {
244 var stream = _incoming; 244 var stream = _incoming;
245 if (headers.value(HttpHeaders.CONTENT_ENCODING) == "gzip") { 245 if (headers.value(HttpHeaders.CONTENT_ENCODING) == "gzip") {
246 stream = stream.transform(new ZLibInflater()); 246 stream = stream.transform(GZIP.decoder);
247 } 247 }
248 return stream.listen(onData, 248 return stream.listen(onData,
249 onError: onError, 249 onError: onError,
250 onDone: onDone, 250 onDone: onDone,
251 cancelOnError: cancelOnError); 251 cancelOnError: cancelOnError);
252 } 252 }
253 253
254 Future<Socket> detachSocket() { 254 Future<Socket> detachSocket() {
255 _httpClient._connectionClosed(_httpRequest._httpClientConnection); 255 _httpClient._connectionClosed(_httpRequest._httpClientConnection);
256 return _httpRequest._httpClientConnection.detachSocket(); 256 return _httpRequest._httpClientConnection.detachSocket();
(...skipping 252 matching lines...) Expand 10 before | Expand all | Expand 10 after
509 return _writeHeaders() 509 return _writeHeaders()
510 .then((_) { 510 .then((_) {
511 int contentLength = headers.contentLength; 511 int contentLength = headers.contentLength;
512 if (_ignoreBody) { 512 if (_ignoreBody) {
513 stream.drain().catchError((_) {}); 513 stream.drain().catchError((_) {});
514 return _headersSink.close(); 514 return _headersSink.close();
515 } 515 }
516 stream = stream.transform(new _BufferTransformer()); 516 stream = stream.transform(new _BufferTransformer());
517 if (headers.chunkedTransferEncoding) { 517 if (headers.chunkedTransferEncoding) {
518 if (_asGZip) { 518 if (_asGZip) {
519 stream = stream.transform(new ZLibDeflater(gzip: true, level: 6)); 519 stream = stream.transform(GZIP.encoder);
520 } 520 }
521 stream = stream.transform(new _ChunkedTransformer()); 521 stream = stream.transform(new _ChunkedTransformer());
522 } else if (contentLength >= 0) { 522 } else if (contentLength >= 0) {
523 stream = stream.transform( 523 stream = stream.transform(
524 new _ContentLengthValidator(contentLength, _uri)); 524 new _ContentLengthValidator(contentLength, _uri));
525 } 525 }
526 return _headersSink.addStream(stream); 526 return _headersSink.addStream(stream);
527 }); 527 });
528 } 528 }
529 529
(...skipping 1936 matching lines...) Expand 10 before | Expand all | Expand 10 after
2466 final Uri location; 2466 final Uri location;
2467 } 2467 }
2468 2468
2469 String _getHttpVersion() { 2469 String _getHttpVersion() {
2470 var version = Platform.version; 2470 var version = Platform.version;
2471 // Only include major and minor version numbers. 2471 // Only include major and minor version numbers.
2472 int index = version.indexOf('.', version.indexOf('.') + 1); 2472 int index = version.indexOf('.', version.indexOf('.') + 1);
2473 version = version.substring(0, index); 2473 version = version.substring(0, index);
2474 return 'Dart/$version (dart:io)'; 2474 return 'Dart/$version (dart:io)';
2475 } 2475 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698