| 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 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 216 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 227 method, | 227 method, |
| 228 url)); | 228 url)); |
| 229 return request.close(); | 229 return request.close(); |
| 230 }); | 230 }); |
| 231 } | 231 } |
| 232 | 232 |
| 233 StreamSubscription<List<int>> listen(void onData(List<int> event), | 233 StreamSubscription<List<int>> listen(void onData(List<int> event), |
| 234 {void onError(AsyncError error), | 234 {void onError(AsyncError error), |
| 235 void onDone(), | 235 void onDone(), |
| 236 bool unsubscribeOnError}) { | 236 bool unsubscribeOnError}) { |
| 237 return _incoming.listen(onData, | 237 var stream = _incoming; |
| 238 onError: onError, | 238 if (headers.value(HttpHeaders.CONTENT_ENCODING) == "gzip") { |
| 239 onDone: onDone, | 239 stream = stream.transform(new ZLibInflater()); |
| 240 unsubscribeOnError: unsubscribeOnError); | 240 } |
| 241 return stream.listen(onData, |
| 242 onError: onError, |
| 243 onDone: onDone, |
| 244 unsubscribeOnError: unsubscribeOnError); |
| 241 } | 245 } |
| 242 | 246 |
| 243 Future<Socket> detachSocket() { | 247 Future<Socket> detachSocket() { |
| 244 _httpClient._connectionClosed(_httpRequest._httpClientConnection); | 248 _httpClient._connectionClosed(_httpRequest._httpClientConnection); |
| 245 return _httpRequest._httpClientConnection.detachSocket(); | 249 return _httpRequest._httpClientConnection.detachSocket(); |
| 246 } | 250 } |
| 247 | 251 |
| 248 HttpConnectionInfo get connectionInfo => _httpRequest.connectionInfo; | 252 HttpConnectionInfo get connectionInfo => _httpRequest.connectionInfo; |
| 249 | 253 |
| 250 bool get _shouldAuthenticate { | 254 bool get _shouldAuthenticate { |
| (...skipping 713 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 964 var outgoing = new _HttpOutgoing(); | 968 var outgoing = new _HttpOutgoing(); |
| 965 // Create new request object, wrapping the outgoing connection. | 969 // Create new request object, wrapping the outgoing connection. |
| 966 var request = new _HttpClientRequest(outgoing, | 970 var request = new _HttpClientRequest(outgoing, |
| 967 uri, | 971 uri, |
| 968 method, | 972 method, |
| 969 !isDirect, | 973 !isDirect, |
| 970 _httpClient, | 974 _httpClient, |
| 971 this); | 975 this); |
| 972 request.headers.host = uri.domain; | 976 request.headers.host = uri.domain; |
| 973 request.headers.port = port; | 977 request.headers.port = port; |
| 978 request.headers.set(HttpHeaders.ACCEPT_ENCODING, "gzip"); |
| 974 if (uri.userInfo != null && !uri.userInfo.isEmpty) { | 979 if (uri.userInfo != null && !uri.userInfo.isEmpty) { |
| 975 // If the URL contains user information use that for basic | 980 // If the URL contains user information use that for basic |
| 976 // authorization | 981 // authorization |
| 977 String auth = | 982 String auth = |
| 978 CryptoUtils.bytesToBase64(_encodeString(uri.userInfo)); | 983 CryptoUtils.bytesToBase64(_encodeString(uri.userInfo)); |
| 979 request.headers.set(HttpHeaders.AUTHORIZATION, "Basic $auth"); | 984 request.headers.set(HttpHeaders.AUTHORIZATION, "Basic $auth"); |
| 980 } else { | 985 } else { |
| 981 // Look for credentials. | 986 // Look for credentials. |
| 982 _Credentials cr = _httpClient._findCredentials(uri); | 987 _Credentials cr = _httpClient._findCredentials(uri); |
| 983 if (cr != null) { | 988 if (cr != null) { |
| (...skipping 820 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1804 | 1809 |
| 1805 | 1810 |
| 1806 class _RedirectInfo implements RedirectInfo { | 1811 class _RedirectInfo implements RedirectInfo { |
| 1807 const _RedirectInfo(int this.statusCode, | 1812 const _RedirectInfo(int this.statusCode, |
| 1808 String this.method, | 1813 String this.method, |
| 1809 Uri this.location); | 1814 Uri this.location); |
| 1810 final int statusCode; | 1815 final int statusCode; |
| 1811 final String method; | 1816 final String method; |
| 1812 final Uri location; | 1817 final Uri location; |
| 1813 } | 1818 } |
| OLD | NEW |