Skip to content

Commit

Permalink
feat(uri): add is_absolute method to Uri
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
seanmonstar committed May 1, 2017
1 parent 817232e commit 154ab29
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/uri.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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| {
Expand Down

0 comments on commit 154ab29

Please sign in to comment.