| 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 | 7 class _HttpIncoming |
| 8 extends Stream<List<int>> implements StreamSink<List<int>> { | 8 extends Stream<List<int>> implements StreamSink<List<int>> { |
| 9 final int _transferLength; | 9 final int _transferLength; |
| 10 final Completer _dataCompleter = new Completer(); | 10 final Completer _dataCompleter = new Completer(); |
| (...skipping 296 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 307 return this; | 307 return this; |
| 308 } | 308 } |
| 309 }); | 309 }); |
| 310 } | 310 } |
| 311 // No credentials were found and the callback was not set. | 311 // No credentials were found and the callback was not set. |
| 312 return new Future.immediate(this); | 312 return new Future.immediate(this); |
| 313 } | 313 } |
| 314 } | 314 } |
| 315 | 315 |
| 316 | 316 |
| 317 class _HttpOutboundMessage<T> extends IOSink { | 317 abstract class _HttpOutboundMessage<T> extends IOSink { |
| 318 // Used to mark when the body should be written. This is used for HEAD | 318 // Used to mark when the body should be written. This is used for HEAD |
| 319 // requests and in error handling. | 319 // requests and in error handling. |
| 320 bool _ignoreBody = false; | 320 bool _ignoreBody = false; |
| 321 | 321 |
| 322 _HttpOutboundMessage(String protocolVersion, _HttpOutgoing outgoing) | 322 _HttpOutboundMessage(String protocolVersion, _HttpOutgoing outgoing) |
| 323 : super(outgoing), | 323 : super(outgoing), |
| 324 _outgoing = outgoing, | 324 _outgoing = outgoing, |
| 325 headers = new _HttpHeaders(protocolVersion); | 325 headers = new _HttpHeaders(protocolVersion); |
| 326 | 326 |
| 327 int get contentLength => headers.contentLength; | 327 int get contentLength => headers.contentLength; |
| 328 void set contentLength(int contentLength) { | 328 void set contentLength(int contentLength) { |
| 329 headers.contentLength = contentLength; | 329 headers.contentLength = contentLength; |
| 330 } | 330 } |
| 331 | 331 |
| 332 bool get persistentConnection => headers.persistentConnection; | 332 bool get persistentConnection => headers.persistentConnection; |
| 333 bool set persistentConnection(bool p) { | 333 void set persistentConnection(bool p) { |
| 334 headers.persistentConnection = p; | 334 headers.persistentConnection = p; |
| 335 } | 335 } |
| 336 | 336 |
| 337 Future<T> consume(Stream<List<int>> stream) { | 337 Future<T> consume(Stream<List<int>> stream) { |
| 338 _writeHeaders(); | 338 _writeHeaders(); |
| 339 if (_ignoreBody) return new Future.immediate(this); | 339 if (_ignoreBody) return new Future.immediate(this); |
| 340 if (_chunked) { | 340 if (_chunked) { |
| 341 // Transform when chunked. | 341 // Transform when chunked. |
| 342 stream = stream.transform(new _ChunkedTransformer()); | 342 stream = stream.transform(new _ChunkedTransformer()); |
| 343 } | 343 } |
| (...skipping 711 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1055 return info.connection.send(uri, | 1055 return info.connection.send(uri, |
| 1056 port, | 1056 port, |
| 1057 method.toUpperCase(), | 1057 method.toUpperCase(), |
| 1058 info.proxy.isDirect); | 1058 info.proxy.isDirect); |
| 1059 }); | 1059 }); |
| 1060 } | 1060 } |
| 1061 | 1061 |
| 1062 Future<HttpClientRequest> _openUrlFromRequest(String method, | 1062 Future<HttpClientRequest> _openUrlFromRequest(String method, |
| 1063 Uri uri, | 1063 Uri uri, |
| 1064 _HttpClientRequest previous) { | 1064 _HttpClientRequest previous) { |
| 1065 return openUrl(method, uri).then((request) { | 1065 return openUrl(method, uri).then((_HttpClientRequest request) { |
| 1066 // Only follow redirects if initial request did. | 1066 // Only follow redirects if initial request did. |
| 1067 request.followRedirects = previous.followRedirects; | 1067 request.followRedirects = previous.followRedirects; |
| 1068 // Allow same number of redirects. | 1068 // Allow same number of redirects. |
| 1069 request.maxRedirects = previous.maxRedirects; | 1069 request.maxRedirects = previous.maxRedirects; |
| 1070 // Copy headers | 1070 // Copy headers |
| 1071 for (var header in previous.headers._headers.keys) { | 1071 for (var header in previous.headers._headers.keys) { |
| 1072 if (request.headers[header] == null) { | 1072 if (request.headers[header] == null) { |
| 1073 request.headers.set(header, previous.headers[header]); | 1073 request.headers.set(header, previous.headers[header]); |
| 1074 } | 1074 } |
| 1075 } | 1075 } |
| (...skipping 409 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1485 Future<Socket> addStream(Stream<List<int>> stream) { | 1485 Future<Socket> addStream(Stream<List<int>> stream) { |
| 1486 return _socket.addStream(stream); | 1486 return _socket.addStream(stream); |
| 1487 } | 1487 } |
| 1488 | 1488 |
| 1489 void addString(String string, [Encoding encoding = Encoding.UTF_8]) { | 1489 void addString(String string, [Encoding encoding = Encoding.UTF_8]) { |
| 1490 return _socket.addString(string, encoding); | 1490 return _socket.addString(string, encoding); |
| 1491 } | 1491 } |
| 1492 | 1492 |
| 1493 void destroy() => _socket.destroy(); | 1493 void destroy() => _socket.destroy(); |
| 1494 void add(List<int> data) => _socket.add(data); | 1494 void add(List<int> data) => _socket.add(data); |
| 1495 Future<Socket> close() => _socket.close(); | 1495 void close() => _socket.close(); |
| 1496 } | 1496 } |
| 1497 | 1497 |
| 1498 | 1498 |
| 1499 class _AuthenticationScheme { | 1499 class _AuthenticationScheme { |
| 1500 static const UNKNOWN = const _AuthenticationScheme(-1); | 1500 static const UNKNOWN = const _AuthenticationScheme(-1); |
| 1501 static const BASIC = const _AuthenticationScheme(0); | 1501 static const BASIC = const _AuthenticationScheme(0); |
| 1502 static const DIGEST = const _AuthenticationScheme(1); | 1502 static const DIGEST = const _AuthenticationScheme(1); |
| 1503 | 1503 |
| 1504 const _AuthenticationScheme(this._scheme); | 1504 const _AuthenticationScheme(this._scheme); |
| 1505 | 1505 |
| (...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1601 | 1601 |
| 1602 | 1602 |
| 1603 class _RedirectInfo implements RedirectInfo { | 1603 class _RedirectInfo implements RedirectInfo { |
| 1604 const _RedirectInfo(int this.statusCode, | 1604 const _RedirectInfo(int this.statusCode, |
| 1605 String this.method, | 1605 String this.method, |
| 1606 Uri this.location); | 1606 Uri this.location); |
| 1607 final int statusCode; | 1607 final int statusCode; |
| 1608 final String method; | 1608 final String method; |
| 1609 final Uri location; | 1609 final Uri location; |
| 1610 } | 1610 } |
| OLD | NEW |