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 1560 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1571 _proxyCredentials.add(new _ProxyCredentials(host, port, realm, cr)); | 1571 _proxyCredentials.add(new _ProxyCredentials(host, port, realm, cr)); |
1572 } | 1572 } |
1573 | 1573 |
1574 set findProxy(String f(Uri uri)) => _findProxy = f; | 1574 set findProxy(String f(Uri uri)) => _findProxy = f; |
1575 | 1575 |
1576 Future<HttpClientRequest> _openUrl(String method, Uri uri) { | 1576 Future<HttpClientRequest> _openUrl(String method, Uri uri) { |
1577 if (method == null) { | 1577 if (method == null) { |
1578 throw new ArgumentError(method); | 1578 throw new ArgumentError(method); |
1579 } | 1579 } |
1580 if (method != "CONNECT") { | 1580 if (method != "CONNECT") { |
1581 if (uri.host.isEmpty || | 1581 if (uri.host.isEmpty) { |
1582 (uri.scheme != "http" && uri.scheme != "https")) { | 1582 throw new ArgumentError("No host specified in URI $uri"); |
1583 throw new ArgumentError("Unsupported scheme '${uri.scheme}' in $uri"); | 1583 } else if (uri.scheme != "http" && uri.scheme != "https") { |
| 1584 throw new ArgumentError( |
| 1585 "Unsupported scheme '${uri.scheme}' in URI $uri"); |
1584 } | 1586 } |
1585 } | 1587 } |
1586 | 1588 |
1587 bool isSecure = (uri.scheme == "https"); | 1589 bool isSecure = (uri.scheme == "https"); |
1588 int port = uri.port; | 1590 int port = uri.port; |
1589 if (port == 0) { | 1591 if (port == 0) { |
1590 port = isSecure ? | 1592 port = isSecure ? |
1591 HttpClient.DEFAULT_HTTPS_PORT : | 1593 HttpClient.DEFAULT_HTTPS_PORT : |
1592 HttpClient.DEFAULT_HTTP_PORT; | 1594 HttpClient.DEFAULT_HTTP_PORT; |
1593 } | 1595 } |
(...skipping 925 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2519 final Uri location; | 2521 final Uri location; |
2520 } | 2522 } |
2521 | 2523 |
2522 String _getHttpVersion() { | 2524 String _getHttpVersion() { |
2523 var version = Platform.version; | 2525 var version = Platform.version; |
2524 // Only include major and minor version numbers. | 2526 // Only include major and minor version numbers. |
2525 int index = version.indexOf('.', version.indexOf('.') + 1); | 2527 int index = version.indexOf('.', version.indexOf('.') + 1); |
2526 version = version.substring(0, index); | 2528 version = version.substring(0, index); |
2527 return 'Dart/$version (dart:io)'; | 2529 return 'Dart/$version (dart:io)'; |
2528 } | 2530 } |
OLD | NEW |