[−][src]Struct hawk::Request
Request represents a single HTTP request.
The structure is created using (RequestBuilder)[struct.RequestBuilder.html]. Most uses of this library will hold several of the fields in this structure fixed. Cloning the structure with these fields applied is a convenient way to avoid repeating those fields. Most fields are references, since in common use the values already exist and will outlive the request.
A request can be used on the client, to generate a header or a bewit, or on the server, to validate the same.
Examples
use hawk::RequestBuilder; let bldr = RequestBuilder::new("GET", "mysite.com", 443, "/"); let request1 = bldr.clone().method("POST").path("/api/user").request(); let request2 = bldr.path("/api/users").request();
See the documentation in the crate root for examples of creating and validating headers.
Methods
impl<'a> Request<'a>
[src]
pub fn make_header(&self, credentials: &Credentials) -> Result<Header>
[src]
Create a new Header for this request, inventing a new nonce and setting the timestamp to the current time.
pub fn make_header_full<S>(
&self,
credentials: &Credentials,
ts: SystemTime,
nonce: S
) -> Result<Header> where
S: Into<String>,
[src]
&self,
credentials: &Credentials,
ts: SystemTime,
nonce: S
) -> Result<Header> where
S: Into<String>,
Similar to make_header
, but allowing specification of the timestamp
and nonce.
pub fn make_bewit(
&self,
credentials: &'a Credentials,
exp: SystemTime
) -> Result<Bewit<'a>>
[src]
&self,
credentials: &'a Credentials,
exp: SystemTime
) -> Result<Bewit<'a>>
Make a "bewit" that can be attached to a URL to authenticate GET access.
The ttl gives the time for which this bewit is valid, starting now.
pub fn make_bewit_with_ttl(
&self,
credentials: &'a Credentials,
ttl: Duration
) -> Result<Bewit<'a>>
[src]
&self,
credentials: &'a Credentials,
ttl: Duration
) -> Result<Bewit<'a>>
Variant of make_bewit
that takes a Duration (starting from now)
instead of a SystemTime, provided for convenience.
pub fn validate_header(
&self,
header: &Header,
key: &Key,
ts_skew: Duration
) -> bool
[src]
&self,
header: &Header,
key: &Key,
ts_skew: Duration
) -> bool
Validate the given header. This validates that the mac
field matches that calculated
using the other header fields and the given request information.
The header's timestamp is verified to be within ts_skew
of the current time. If any of
the required header fields are missing, the method will return false.
It is up to the caller to examine the header's id
field and supply the corresponding key.
If desired, it is up to the caller to validate that nonce
has not been used before.
If a hash has been supplied, then the header must contain a matching hash. Note that this hash must be calculated based on the request body, not copied from the request header!
pub fn validate_bewit(&self, bewit: &Bewit, key: &Key) -> bool
[src]
Validate the given bewit matches this request.
It is up to the caller to consult the Bewit's id
and look up the
corresponding key.
Nonces and hashes do not apply when using bewits.
pub fn make_response_builder(
&'a self,
req_header: &'a Header
) -> ResponseBuilder<'a>
[src]
&'a self,
req_header: &'a Header
) -> ResponseBuilder<'a>
Get a Response instance for a response to this request. This is a convenience
wrapper around Response::from_request_header
.
Trait Implementations
Auto Trait Implementations
impl<'a> RefUnwindSafe for Request<'a>
impl<'a> Send for Request<'a>
impl<'a> Sync for Request<'a>
impl<'a> Unpin for Request<'a>
impl<'a> UnwindSafe for Request<'a>
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
fn to_owned(&self) -> T
[src]
fn clone_into(&self, target: &mut T)
[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
V: MultiLane<T>,