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 /** | 7 /** |
8 * HTTP status codes. | 8 * HTTP status codes. |
9 */ | 9 */ |
10 abstract class HttpStatus { | 10 abstract class HttpStatus { |
(...skipping 925 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
936 * `Dart/<version> (dart:io)`. | 936 * `Dart/<version> (dart:io)`. |
937 * | 937 * |
938 * If the userAgent is set to `null`, no default `User-Agent` header will be | 938 * If the userAgent is set to `null`, no default `User-Agent` header will be |
939 * added to each request. | 939 * added to each request. |
940 */ | 940 */ |
941 String userAgent; | 941 String userAgent; |
942 | 942 |
943 factory HttpClient() => new _HttpClient(); | 943 factory HttpClient() => new _HttpClient(); |
944 | 944 |
945 /** | 945 /** |
946 * Opens a HTTP connection. The returned [HttpClientRequest] is used to | 946 * Opens a HTTP connection. |
947 * fill in the content of the request before sending it. The 'host' header for | 947 * |
948 * the request will be set to the value [host]:[port]. This can be overridden | 948 * The HTTP method to use is specified in [method], the server is |
949 * through the [HttpClientRequest] interface before the request is sent. | 949 * specified using [host] and [port], and the path (including |
950 * NOTE if [host] is an IP address this will still be set in the 'host' | 950 * possible fragment and query) is specified using [path]. |
| 951 * |
| 952 * The `Host` header for the request will be set to the value |
| 953 * [host]:[port]. This can be overridden through the |
| 954 * [HttpClientRequest] interface before the request is sent. NOTE |
| 955 * if [host] is an IP address this will still be set in the `Host` |
951 * header. | 956 * header. |
| 957 * |
| 958 * For additional information on the sequence of events during an |
| 959 * HTTP transaction, and the objects returned by the futures, see |
| 960 * the overall documentation for the class [HttpClient]. |
952 */ | 961 */ |
953 Future<HttpClientRequest> open(String method, | 962 Future<HttpClientRequest> open(String method, |
954 String host, | 963 String host, |
955 int port, | 964 int port, |
956 String path); | 965 String path); |
957 | 966 |
958 /** | 967 /** |
959 * Opens a HTTP connection. The returned [HttpClientRequest] is used to | 968 * Opens a HTTP connection. |
960 * fill in the content of the request before sending it. The 'hosth header for | 969 * |
961 * the request will be set to the value [host]:[port]. This can be overridden | 970 * The HTTP method is specified in [method] and the URL to use in |
962 * through the [HttpClientRequest] interface before the request is sent. | 971 * [url]. |
963 * NOTE if [host] is an IP address this will still be set in the 'host' | 972 * |
| 973 * The `Host` header for the request will be set to the value |
| 974 * [host]:[port]. This can be overridden through the |
| 975 * [HttpClientRequest] interface before the request is sent. NOTE |
| 976 * if [host] is an IP address this will still be set in the `Host` |
964 * header. | 977 * header. |
| 978 * |
| 979 * For additional information on the sequence of events during an |
| 980 * HTTP transaction, and the objects returned by the futures, see |
| 981 * the overall documentation for the class [HttpClient]. |
965 */ | 982 */ |
966 Future<HttpClientRequest> openUrl(String method, Uri url); | 983 Future<HttpClientRequest> openUrl(String method, Uri url); |
967 | 984 |
968 /** | 985 /** |
969 * Opens a HTTP connection using the GET method. See [open] for | 986 * Opens a HTTP connection using the GET method. |
970 * details. Using this method to open a HTTP connection will set the | 987 * |
971 * content length to 0. | 988 * The server is specified using [host] and [port], and the path |
| 989 * (including possible fragment and query) is specified using |
| 990 * [path]. |
| 991 * |
| 992 * See [open] for details. |
972 */ | 993 */ |
973 Future<HttpClientRequest> get(String host, int port, String path); | 994 Future<HttpClientRequest> get(String host, int port, String path); |
974 | 995 |
975 /** | 996 /** |
976 * Opens a HTTP connection using the GET method. See [openUrl] for | 997 * Opens a HTTP connection using the GET method. |
977 * details. Using this method to open a HTTP connection will set the | 998 * |
978 * content length to 0. | 999 * The URL to use is specified in [url]. |
| 1000 * |
| 1001 * See [openUrl] for details. |
979 */ | 1002 */ |
980 Future<HttpClientRequest> getUrl(Uri url); | 1003 Future<HttpClientRequest> getUrl(Uri url); |
981 | 1004 |
982 /** | 1005 /** |
983 * Opens a HTTP connection using the POST method. See [open] for details. | 1006 * Opens a HTTP connection using the POST method. |
| 1007 * |
| 1008 * The server is specified using [host] and [port], and the path |
| 1009 * (including possible fragment and query) is specified using |
| 1010 * [path]. |
| 1011 * |
| 1012 * See [open] for details. |
984 */ | 1013 */ |
985 Future<HttpClientRequest> post(String host, int port, String path); | 1014 Future<HttpClientRequest> post(String host, int port, String path); |
986 | 1015 |
987 /** | 1016 /** |
988 * Opens a HTTP connection using the POST method. See [openUrl] for details. | 1017 * Opens a HTTP connection using the POST method. |
| 1018 * |
| 1019 * The URL to use is specified in [url]. |
| 1020 * |
| 1021 * See [openUrl] for details. |
989 */ | 1022 */ |
990 Future<HttpClientRequest> postUrl(Uri url); | 1023 Future<HttpClientRequest> postUrl(Uri url); |
991 | 1024 |
992 /** | 1025 /** |
993 * Sets the function to be called when a site is requesting | 1026 * Sets the function to be called when a site is requesting |
994 * authentication. The URL requested and the security realm from the | 1027 * authentication. The URL requested and the security realm from the |
995 * server are passed in the arguments [url] and [realm]. | 1028 * server are passed in the arguments [url] and [realm]. |
996 * | 1029 * |
997 * The function returns a [Future] which should complete when the | 1030 * The function returns a [Future] which should complete when the |
998 * authentication has been resolved. If credentials cannot be | 1031 * authentication has been resolved. If credentials cannot be |
(...skipping 436 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1435 | 1468 |
1436 class RedirectException implements HttpException { | 1469 class RedirectException implements HttpException { |
1437 final String message; | 1470 final String message; |
1438 final List<RedirectInfo> redirects; | 1471 final List<RedirectInfo> redirects; |
1439 | 1472 |
1440 const RedirectException(String this.message, | 1473 const RedirectException(String this.message, |
1441 List<RedirectInfo> this.redirects); | 1474 List<RedirectInfo> this.redirects); |
1442 | 1475 |
1443 String toString() => "RedirectException: $message"; | 1476 String toString() => "RedirectException: $message"; |
1444 } | 1477 } |
OLD | NEW |