Chromium Code Reviews| 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 908 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 919 */ | 919 */ |
| 920 set findProxy(String f(Uri url)); | 920 set findProxy(String f(Uri url)); |
| 921 | 921 |
| 922 /** | 922 /** |
| 923 * Function for resolving the proxy server to be used for a HTTP | 923 * Function for resolving the proxy server to be used for a HTTP |
| 924 * connection from the proxy configuration specified through | 924 * connection from the proxy configuration specified through |
| 925 * environment variables. | 925 * environment variables. |
| 926 * | 926 * |
| 927 * The following environment variables are taken into account: | 927 * The following environment variables are taken into account: |
| 928 * | 928 * |
| 929 * * http_proxy | 929 * http_proxy |
| 930 * * https_proxy | 930 * https_proxy |
| 931 * * no_proxy | 931 * no_proxy |
| 932 * * HTTP_PROXY | 932 * HTTP_PROXY |
| 933 * * HTTPS_PROXY | 933 * HTTPS_PROXY |
| 934 * * NO_PROXY | 934 * NO_PROXY |
| 935 * | 935 * |
| 936 * [:http_proxy:] and [:HTTP_PROXY:] specify the proxy server to use for | 936 * [:http_proxy:] and [:HTTP_PROXY:] specify the proxy server to use for |
| 937 * http:// urls. Use the format [:hostname:port:]. If no port is used a | 937 * http:// urls. Use the format [:hostname:port:]. If no port is used a |
| 938 * default of 1080 will be used. If both are set the lower case one takes | 938 * default of 1080 will be used. If both are set the lower case one takes |
| 939 * precedence. | 939 * precedence. |
| 940 * | 940 * |
| 941 * [:https_proxy:] and [:HTTPS_PROXY:] specify the proxy server to use for | 941 * [:https_proxy:] and [:HTTPS_PROXY:] specify the proxy server to use for |
| 942 * https:// urls. Use the format [:hostname:port:]. If no port is used a | 942 * https:// urls. Use the format [:hostname:port:]. If no port is used a |
| 943 * default of 1080 will be used. If both are set the lower case one takes | 943 * default of 1080 will be used. If both are set the lower case one takes |
| 944 * precedence. | 944 * precedence. |
| (...skipping 11 matching lines...) Expand all Loading... | |
| 956 * client.findProxy = HttpClient.findProxyFromEnvironment; | 956 * client.findProxy = HttpClient.findProxyFromEnvironment; |
| 957 * | 957 * |
| 958 * If you don't want to use the system environment you can use a | 958 * If you don't want to use the system environment you can use a |
| 959 * different one by wrapping the function. | 959 * different one by wrapping the function. |
| 960 * | 960 * |
| 961 * HttpClient client = new HttpClient(); | 961 * HttpClient client = new HttpClient(); |
| 962 * client.findProxy = (url) { | 962 * client.findProxy = (url) { |
| 963 * return HttpClient.findProxyFromEnvironment( | 963 * return HttpClient.findProxyFromEnvironment( |
| 964 * url, {"http_proxy": ..., "no_proxy": ...}); | 964 * url, {"http_proxy": ..., "no_proxy": ...}); |
| 965 * } | 965 * } |
| 966 * | |
| 967 * If a proxy requires authentication it is possible to configure | |
| 968 * the username and password as well. Use the format | |
| 969 * [:username:password@hostname:port:] to include the username and | |
| 970 * password. Alternatively the API [addProxyCredentials] can be used | |
| 971 * to set credentials for proxies which require authentication. | |
| 966 */ | 972 */ |
| 967 static String findProxyFromEnvironment(Uri url, | 973 static String findProxyFromEnvironment(Uri url, |
| 968 {Map<String, String> environment}) { | 974 {Map<String, String> environment}) { |
| 969 return _HttpClient._findProxyFromEnvironment(url, environment); | 975 return _HttpClient._findProxyFromEnvironment(url, environment); |
| 970 } | 976 } |
| 971 | 977 |
| 972 /** | 978 /** |
| 979 * Sets the function to be called when a proxy is requesting | |
| 980 * authentication. The proxy used and and the security realm from | |
|
Anders Johnsen
2013/04/15 07:07:19
double 'and'. Rewrite first part of the sentence.
Søren Gjesse
2013/04/15 07:42:00
Done.
| |
| 981 * the server are passed in the arguments [host], [port] and | |
| 982 * [realm]. | |
| 983 * | |
| 984 * The function returns a [Future] which should complete when the | |
| 985 * authentication has been resolved. If credentials cannot be | |
| 986 * provided the [Future] should complete with [false]. If | |
| 987 * credentials are available the function should add these using | |
| 988 * [addProxyCredentials] before completing the [Future] with the value | |
| 989 * [true]. | |
| 990 * | |
| 991 * If the [Future] completes with [true] the request will be retried | |
| 992 * using the updated credentials. Otherwise response processing will | |
| 993 * continue normally. | |
| 994 */ | |
| 995 set authenticateProxy( | |
| 996 Future<bool> f(String host, int port, String scheme, String realm)); | |
| 997 | |
| 998 /** | |
| 999 * Add credentials to be used for authorizing HTTP proxies. | |
| 1000 */ | |
| 1001 void addProxyCredentials(String host, | |
| 1002 int port, | |
| 1003 String realm, | |
| 1004 HttpClientCredentials credentials); | |
| 1005 | |
| 1006 /** | |
| 973 * Shutdown the HTTP client. If [force] is [:false:] (the default) | 1007 * Shutdown the HTTP client. If [force] is [:false:] (the default) |
| 974 * the [:HttpClient:] will be kept alive until all active | 1008 * the [:HttpClient:] will be kept alive until all active |
| 975 * connections are done. If [force] is [:true:] any active | 1009 * connections are done. If [force] is [:true:] any active |
| 976 * connections will be closed to immediately release all | 1010 * connections will be closed to immediately release all |
| 977 * resources. These closed connections will receive an [:onError:] | 1011 * resources. These closed connections will receive an [:onError:] |
| 978 * callback to indicate that the client was shutdown. In both cases | 1012 * callback to indicate that the client was shutdown. In both cases |
| 979 * trying to establish a new connection after calling [shutdown] | 1013 * trying to establish a new connection after calling [shutdown] |
| 980 * will throw an exception. | 1014 * will throw an exception. |
| 981 */ | 1015 */ |
| 982 void close({bool force: false}); | 1016 void close({bool force: false}); |
| (...skipping 282 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1265 class RedirectLimitExceededException extends RedirectException { | 1299 class RedirectLimitExceededException extends RedirectException { |
| 1266 const RedirectLimitExceededException(List<RedirectInfo> redirects) | 1300 const RedirectLimitExceededException(List<RedirectInfo> redirects) |
| 1267 : super("Redirect limit exceeded", redirects); | 1301 : super("Redirect limit exceeded", redirects); |
| 1268 } | 1302 } |
| 1269 | 1303 |
| 1270 | 1304 |
| 1271 class RedirectLoopException extends RedirectException { | 1305 class RedirectLoopException extends RedirectException { |
| 1272 const RedirectLoopException(List<RedirectInfo> redirects) | 1306 const RedirectLoopException(List<RedirectInfo> redirects) |
| 1273 : super("Redirect loop detected", redirects); | 1307 : super("Redirect loop detected", redirects); |
| 1274 } | 1308 } |
| OLD | NEW |