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 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 413 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
424 | 424 |
425 final Uri _uri; | 425 final Uri _uri; |
426 final _HttpOutgoing _outgoing; | 426 final _HttpOutgoing _outgoing; |
427 | 427 |
428 final _HttpHeaders headers; | 428 final _HttpHeaders headers; |
429 | 429 |
430 _HttpOutboundMessage(Uri uri, | 430 _HttpOutboundMessage(Uri uri, |
431 String protocolVersion, | 431 String protocolVersion, |
432 _HttpOutgoing outgoing, | 432 _HttpOutgoing outgoing, |
433 {_HttpHeaders initialHeaders}) | 433 {_HttpHeaders initialHeaders}) |
434 : super(outgoing, null), | 434 : _uri = uri, |
435 _uri = uri, | |
436 headers = new _HttpHeaders( | 435 headers = new _HttpHeaders( |
437 protocolVersion, | 436 protocolVersion, |
438 defaultPortForScheme: uri.scheme == 'https' ? | 437 defaultPortForScheme: uri.scheme == 'https' ? |
439 HttpClient.DEFAULT_HTTPS_PORT : | 438 HttpClient.DEFAULT_HTTPS_PORT : |
440 HttpClient.DEFAULT_HTTP_PORT, | 439 HttpClient.DEFAULT_HTTP_PORT, |
441 initialHeaders: initialHeaders), | 440 initialHeaders: initialHeaders), |
442 _outgoing = outgoing { | 441 _outgoing = outgoing, |
| 442 super(outgoing, null) { |
443 _outgoing.outbound = this; | 443 _outgoing.outbound = this; |
444 _encodingMutable = false; | 444 _encodingMutable = false; |
445 } | 445 } |
446 | 446 |
447 int get contentLength => headers.contentLength; | 447 int get contentLength => headers.contentLength; |
448 void set contentLength(int contentLength) { | 448 void set contentLength(int contentLength) { |
449 headers.contentLength = contentLength; | 449 headers.contentLength = contentLength; |
450 } | 450 } |
451 | 451 |
452 bool get persistentConnection => headers.persistentConnection; | 452 bool get persistentConnection => headers.persistentConnection; |
(...skipping 258 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
711 | 711 |
712 // TODO(ajohnsen): Get default value from client? | 712 // TODO(ajohnsen): Get default value from client? |
713 bool _followRedirects = true; | 713 bool _followRedirects = true; |
714 | 714 |
715 int _maxRedirects = 5; | 715 int _maxRedirects = 5; |
716 | 716 |
717 List<RedirectInfo> _responseRedirects = []; | 717 List<RedirectInfo> _responseRedirects = []; |
718 | 718 |
719 _HttpClientRequest(_HttpOutgoing outgoing, Uri uri, this.method, this._proxy, | 719 _HttpClientRequest(_HttpOutgoing outgoing, Uri uri, this.method, this._proxy, |
720 this._httpClient, this._httpClientConnection) | 720 this._httpClient, this._httpClientConnection) |
721 : super(uri, "1.1", outgoing), | 721 : uri = uri, |
722 uri = uri { | 722 super(uri, "1.1", outgoing) { |
723 // GET and HEAD have 'content-length: 0' by default. | 723 // GET and HEAD have 'content-length: 0' by default. |
724 if (method == "GET" || method == "HEAD") { | 724 if (method == "GET" || method == "HEAD") { |
725 contentLength = 0; | 725 contentLength = 0; |
726 } else { | 726 } else { |
727 headers.chunkedTransferEncoding = true; | 727 headers.chunkedTransferEncoding = true; |
728 } | 728 } |
729 } | 729 } |
730 | 730 |
731 Future<HttpClientResponse> get done { | 731 Future<HttpClientResponse> get done { |
732 if (_response == null) { | 732 if (_response == null) { |
(...skipping 2131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2864 const _RedirectInfo(this.statusCode, this.method, this.location); | 2864 const _RedirectInfo(this.statusCode, this.method, this.location); |
2865 } | 2865 } |
2866 | 2866 |
2867 String _getHttpVersion() { | 2867 String _getHttpVersion() { |
2868 var version = Platform.version; | 2868 var version = Platform.version; |
2869 // Only include major and minor version numbers. | 2869 // Only include major and minor version numbers. |
2870 int index = version.indexOf('.', version.indexOf('.') + 1); | 2870 int index = version.indexOf('.', version.indexOf('.') + 1); |
2871 version = version.substring(0, index); | 2871 version = version.substring(0, index); |
2872 return 'Dart/$version (dart:io)'; | 2872 return 'Dart/$version (dart:io)'; |
2873 } | 2873 } |
OLD | NEW |