Function aws_sdk_rust::http::client::proxy::https_proxy
[−]
[src]
pub fn https_proxy() -> Result<Option<Proxy>>
Returns a Proxy
from the https_proxy
environment variable, if it is set.
The value of https_proxy
must be a parseable URL such as https://proxy.company.com:8001/
otherwise a parsing error will be returned. If the port is not present, than the default port
numbers of http/80 and https/443 will be returned. If the https_proxy
environment variable is
not set or is empty, then a Result
of None
will be returned.
References:
- https://www.gnu.org/software/wget/manual/html_node/Proxies.html
- https://wiki.archlinux.org/index.php/proxy_settings
- https://msdn.microsoft.com/en-us/library/hh272656(v=vs.120).aspx
- http://www.cyberciti.biz/faq/linux-unix-set-proxy-environment-variable/
Examples
Behavior when environment variable is set:
use std; use habitat_http_client::proxy; std::env::set_var("https_proxy", "http://proxy.example.com:8001/"); let info = proxy::https_proxy().unwrap().unwrap(); assert_eq!(info.scheme(), "http"); assert_eq!(info.host(), "proxy.example.com"); assert_eq!(info.port(), 8001); assert!(info.authorization_header_value().is_none());
Behavior when environment variable is set with basic auth credentials:
use std; use habitat_http_client::proxy; std::env::set_var("https_proxy", "http://itsme:asecret@proxy.example.com"); let info = proxy::https_proxy().unwrap().unwrap(); assert_eq!(info.scheme(), "http"); assert_eq!(info.host(), "proxy.example.com"); assert_eq!(info.port(), 80); assert_eq!(info.authorization_header_value().unwrap(), "Basic aXRzbWU6YXNlY3JldA==");
Behavior when both lower case and upper case environment variables are set:
use std; use habitat_http_client::proxy; std::env::set_var("https_proxy", "http://lower.example.com"); std::env::set_var("HTTPS_PROXY", "http://upper.example.com"); let info = proxy::https_proxy().unwrap().unwrap(); assert_eq!(info.host(), "lower.example.com");
Behavior when environment variable is empty:
use std; use habitat_http_client::proxy; std::env::set_var("https_proxy", ""); assert!(proxy::https_proxy().unwrap().is_none());
Errors
- If the value of the
https_proxy
environment variable cannot be parsed as a URL - If the URL scheme is not a valid type (currently only supported schemes are http and https)
- If the URL is missing a host/domain segement
- If the URL is missing a port number and a default cannot be determined