redirect
ModuleThe redirect policy: when a response is a redirect, where it leads (RFC 3986 reference resolution) and which credentials it may carry there.
Contents
use utopia_client::redirect::is_redirect;pub fn is_redirect(response: &Response) -> boolWhether a response is a redirect to follow: a 3xx status with a
non-empty Location.
use utopia_client::redirect::is_same_origin;pub fn is_same_origin(from: &Uri, to: &Uri) -> boolWhether two URIs share an origin: scheme, host and port (the scheme's default when absent), compared case-insensitively.
use utopia_client::redirect::remove_dot_segments;pub fn remove_dot_segments(path: &str) -> StringRFC 3986 §5.2.4 remove_dot_segments.
use utopia_client::redirect::resolve;pub fn resolve(base: &Uri, location: &str) -> Result<Uri, Error>Resolves a Location against the URI it was received for (RFC 3986
§5.2), removing dot segments.
Fails with Error::InvalidArgument (Invalid URI.) when the location
does not parse.
use utopia_client::{redirect, Uri};
let base = Uri::parse("https://example.com/a/b/c?q=1")?;
assert_eq!(redirect::resolve(&base, "../d")?.to_string(), "https://example.com/a/d");
assert_eq!(redirect::resolve(&base, "//cdn.example.com/x")?.to_string(), "https://cdn.example.com/x");
assert_eq!(redirect::resolve(&base, "#top")?.to_string(), "https://example.com/a/b/c?q=1#top");use utopia_client::redirect::should_strip_sensitive_headers;pub fn should_strip_sensitive_headers(from: &Uri, to: &Uri) -> boolWhether a hop from from to to must drop credentials: whenever the
origin changes, so an HTTPS to HTTP hop on the same host too.
use utopia_client::redirect::without_sensitive_headers;pub fn without_sensitive_headers(headers: &mut Headers)Removes Authorization, Cookie, Cookie2 and Proxy-Authorization.
pub const MAX_HOPS: u32 = 50The most redirects a request follows by default.