pub struct Url {
pub scheme: String,
pub host: String,
pub port: u16,
pub path: String,
pub query: Option<String>,
/* private fields */
}Expand description
Parsed URL data used by request builders and transports.
Fields§
§scheme: StringURL scheme (http or https).
host: StringHostname or literal IP address (without IPv6 brackets).
port: u16Effective network port.
path: StringNormalized path component (always starts with /).
query: Option<String>Optional query string without the leading ?.
Implementations§
Source§impl Url
impl Url
Sourcepub fn parse(input: &str) -> Result<Self, NanoGetError>
pub fn parse(input: &str) -> Result<Self, NanoGetError>
Parses a URL string into a Url.
If no scheme is provided, http is assumed.
Sourcepub fn resolve(&self, location: &str) -> Result<Self, NanoGetError>
pub fn resolve(&self, location: &str) -> Result<Self, NanoGetError>
Resolves a redirect location against this URL.
Supports:
- absolute URLs
- scheme-relative URLs
- absolute paths
- relative paths
- query-only redirects
Sourcepub fn origin_form(&self) -> String
pub fn origin_form(&self) -> String
Returns the request-target in origin-form, for example /path?query.
Sourcepub fn absolute_form(&self) -> String
pub fn absolute_form(&self) -> String
Returns the request-target in absolute-form, for proxy HTTP requests.
Returns the request-target in authority-form, for example example.com:443.
Sourcepub fn host_header_value(&self) -> String
pub fn host_header_value(&self) -> String
Returns the value used for the Host header.
Sourcepub fn connect_host_with_port(&self) -> String
pub fn connect_host_with_port(&self) -> String
Returns host:port, with IPv6 hosts bracketed as required.
Sourcepub fn is_default_port(&self) -> bool
pub fn is_default_port(&self) -> bool
Returns true if the port matches the scheme default.
Returns true when scheme, host, and port are identical.