From 154ab29c0d2b50d7bcac0f7918abf2f7a1628112 Mon Sep 17 00:00:00 2001 From: Sean McArthur Date: Wed, 26 Apr 2017 10:15:52 -0700 Subject: [PATCH] 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. --- src/uri.rs | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/uri.rs b/src/uri.rs index c4479b0173..d56ad74f47 100644 --- a/src/uri.rs +++ b/src/uri.rs @@ -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)] fn fragment(&self) -> Option<&str> { self.fragment_start.map(|start| {