| 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 1656 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1667 String host, | 1667 String host, |
| 1668 int port)) { | 1668 int port)) { |
| 1669 _badCertificateCallback = callback; | 1669 _badCertificateCallback = callback; |
| 1670 } | 1670 } |
| 1671 | 1671 |
| 1672 | 1672 |
| 1673 Future<HttpClientRequest> open(String method, | 1673 Future<HttpClientRequest> open(String method, |
| 1674 String host, | 1674 String host, |
| 1675 int port, | 1675 int port, |
| 1676 String path) { | 1676 String path) { |
| 1677 const int _NUMBER_SIGN = 0x23; | 1677 // TODO(sgjesse): The path set here can contain both query and |
| 1678 const int _QUESTION = 0x3F; | 1678 // fragment. They should be cracked and set correctly. |
| 1679 String pathOnly = path; | |
| 1680 String query; | |
| 1681 String fragment; | |
| 1682 // TODO(lrn): Consider dropping the fragment from the Uri. | |
| 1683 for (int i = 0; i < path.length; i++) { | |
| 1684 int char = path.codeUnitAt(i); | |
| 1685 if (char == _NUMBER_SIGN) { | |
| 1686 pathOnly = path.substring(0, i); | |
| 1687 fragment = path.substring(i + 1); | |
| 1688 break; | |
| 1689 } | |
| 1690 if (char == _QUESTION) { | |
| 1691 pathOnly = path.substring(0, i); | |
| 1692 int queryEnd = path.length; | |
| 1693 int fragmentStart = path.indexOf("#", i + 1); | |
| 1694 if (fragmentStart >= 0) { | |
| 1695 queryEnd = fragmentStart; | |
| 1696 fragment = path.substring(fragmentStart + 1); | |
| 1697 } | |
| 1698 query = path.substring(i + 1, queryEnd); | |
| 1699 break; | |
| 1700 } | |
| 1701 } | |
| 1702 return _openUrl(method, new Uri( | 1679 return _openUrl(method, new Uri( |
| 1703 scheme: "http", host: host, port: port, path: pathOnly, | 1680 scheme: "http", host: host, port: port, path: path)); |
| 1704 query: query, fragment: fragment)); | |
| 1705 } | 1681 } |
| 1706 | 1682 |
| 1707 Future<HttpClientRequest> openUrl(String method, Uri url) { | 1683 Future<HttpClientRequest> openUrl(String method, Uri url) { |
| 1708 return _openUrl(method, url); | 1684 return _openUrl(method, url); |
| 1709 } | 1685 } |
| 1710 | 1686 |
| 1711 Future<HttpClientRequest> get(String host, int port, String path) | 1687 Future<HttpClientRequest> get(String host, int port, String path) |
| 1712 => open("get", host, port, path); | 1688 => open("get", host, port, path); |
| 1713 | 1689 |
| 1714 Future<HttpClientRequest> getUrl(Uri url) => _openUrl("get", url); | 1690 Future<HttpClientRequest> getUrl(Uri url) => _openUrl("get", url); |
| (...skipping 1107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2822 const _RedirectInfo(this.statusCode, this.method, this.location); | 2798 const _RedirectInfo(this.statusCode, this.method, this.location); |
| 2823 } | 2799 } |
| 2824 | 2800 |
| 2825 String _getHttpVersion() { | 2801 String _getHttpVersion() { |
| 2826 var version = Platform.version; | 2802 var version = Platform.version; |
| 2827 // Only include major and minor version numbers. | 2803 // Only include major and minor version numbers. |
| 2828 int index = version.indexOf('.', version.indexOf('.') + 1); | 2804 int index = version.indexOf('.', version.indexOf('.') + 1); |
| 2829 version = version.substring(0, index); | 2805 version = version.substring(0, index); |
| 2830 return 'Dart/$version (dart:io)'; | 2806 return 'Dart/$version (dart:io)'; |
| 2831 } | 2807 } |
| OLD | NEW |