http::uri
On this page
URIs (RFC 3986): parsing, normalization, reference resolution,
percent-encoding and application/x-www-form-urlencoded.
Structs
UriSource
pub struct UriA URI reference. scheme is "" and host is none for a
relative reference (/a?b). host keeps an IPv6 literal without
its brackets. Components keep their percent-encoding.
Parse a URI reference strictly: every character must be allowed in its component and every
%must start a%XXescape.host[:port]as aHostheader /:authorityvalue (no userinfo);""without a host.The port, or the scheme's default (80 / 443);
noneif neither.Path and query as a request target (
/for an empty path).The query as
(name, value)pairs (form-decoded).The syntax-based normalization of RFC 3986 plus the scheme-based one for http / https: lowercase scheme and host, uppercase escapes, unreserved characters decoded, dot segments removed, a default port dropped, an empty path made
/.Resolve
referenceagainst this base URI.Resolve the reference text
sagainst this URI.
Trait implementations 1
impl Display for Uri
Functions
remove_dot_segmentsSource
pub fn remove_dot_segments(path: str) -> str path with its . and .. segments resolved.
percent_encodeSource
pub fn percent_encode(s: str, keep: str = "") -> str s with every byte that is not unreserved and not in keep as a
%XX escape (UTF-8 bytes each escaped).
percent_decode_bytesSource
pub fn percent_decode_bytes(s: str) throws (HttpError) -> List<u8> The bytes s encodes; throws on a malformed escape.
percent_decodeSource
pub fn percent_decode(s: str) throws (HttpError) -> str The text s encodes; throws on a malformed escape or invalid UTF-8.
form_encodeSource
pub fn form_encode(pairs: List<(str, str)>) -> str application/x-www-form-urlencoded (WHATWG URL): a=1&b=x+y.
form_decodeSource
pub fn form_decode(s: str) -> List<(str, str)> Decode a form body / query leniently as browsers do: empty pieces
skipped, + is a space, a malformed escape stays as written,
invalid UTF-8 becomes U+FFFD.