Skip to content

Commit 154ab29

Browse files
committed
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.
1 parent 817232e commit 154ab29

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

src/uri.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -190,6 +190,14 @@ impl Uri {
190190
})
191191
}
192192

193+
/// Returns whether this URI is in `absolute-form`.
194+
///
195+
/// An example of absolute form is `https://hyper.rs`.
196+
#[inline]
197+
pub fn is_absolute(&self) -> bool {
198+
self.scheme_end.is_some()
199+
}
200+
193201
#[cfg(test)]
194202
fn fragment(&self) -> Option<&str> {
195203
self.fragment_start.map(|start| {

0 commit comments

Comments
 (0)