Skip to content

Commit

Permalink
request: add Builder::version_ref to query the version in use (#495)
Browse files Browse the repository at this point in the history
This is needed to manually clone `Builder` instances reliably.
  • Loading branch information
mathstuf authored Aug 10, 2021
1 parent 58c6290 commit d2fda20
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions src/request.rs
Original file line number Diff line number Diff line change
Expand Up @@ -878,6 +878,25 @@ impl Builder {
})
}

/// Get the HTTP version for this request
///
/// By default this is HTTP/1.1.
///
/// # Examples
///
/// ```
/// # use http::*;
///
/// let mut req = Request::builder();
/// assert_eq!(req.version_ref().unwrap(), &Version::HTTP_11 );
///
/// req = req.version(Version::HTTP_2);
/// assert_eq!(req.version_ref().unwrap(), &Version::HTTP_2 );
/// ```
pub fn version_ref(&self) -> Option<&Version> {
self.inner.as_ref().ok().map(|h| &h.version)
}

/// Appends a header to this request builder.
///
/// This function will append the provided key/value as a header to the
Expand Down

0 comments on commit d2fda20

Please sign in to comment.