feat(uri): add is_absolute method to Uri

This allows servers to check if an incoming URI is in absolute form.
Especially useful for proxies to determine if the request was meant to
be proxied or aimed directly at the proxy server.
This commit is contained in:
Sean McArthur
2017-04-26 10:15:52 -07:00
parent 817232ec6f
commit 154ab29c0d

View File

@@ -190,6 +190,14 @@ impl Uri {
}) })
} }
/// Returns whether this URI is in `absolute-form`.
///
/// An example of absolute form is `https://hyper.rs`.
#[inline]
pub fn is_absolute(&self) -> bool {
self.scheme_end.is_some()
}
#[cfg(test)] #[cfg(test)]
fn fragment(&self) -> Option<&str> { fn fragment(&self) -> Option<&str> {
self.fragment_start.map(|start| { self.fragment_start.map(|start| {