pub struct ProxyUrl(/* private fields */);Expand description
A wrapper for the proxy URL retrieved from the environment.
This struct will wrap the raw value of the URL, which is only guaranteed to be valid UTF-8 when returned. Various methods exist to extract the value as-is, translate it into other forms, and provide elements of interest.
Implementations§
Source§impl ProxyUrl
impl ProxyUrl
Sourcepub fn with_default_port(self, port: u16) -> Self
pub fn with_default_port(self, port: u16) -> Self
Set the default port to use when transforming the raw URL value if the port isn’t specified in the URL.
A ProxyUrl instance returned by the library will have the default
port set to 8080, which corresponds to http-alt in the IANA port
registry. This is different from curl, which uses port 1080 as the default.
To skip the default port substitution, use [with_no_default_port()]
(#method.with_no_default_port) on the instance.
Sourcepub fn with_no_default_port(self) -> Self
pub fn with_no_default_port(self) -> Self
Don’t use the default port value when transforming the raw URL.
Sourcepub fn to_url(self) -> Option<Url>
pub fn to_url(self) -> Option<Url>
Transform the raw proxy URL into a Url.
The transformation will:
- Parse the raw URL as a
Url. If the raw URL lacks the scheme,httpis assumed and “http://” is prepended to canonicalize the value; - Ensure that the host part is not empty;
- Use the default value for the port (or not, see
with_default_port()) if one is not specified in the raw URL. - Ensure that the port is not empty.
If any of the steps fail, None will be returned.