MockRequest

Struct MockRequest 

Source
pub struct MockRequest { /* private fields */ }
Expand description

A mock request type

Implementations§

Source§

impl MockRequest

Source

pub fn method(&self) -> Method

Returns the method used by this mock request

Source

pub fn path(&self) -> &str

Returns the path used by this mock request

Source

pub fn headers(&self) -> impl IntoIterator<Item = (&HeaderName, &HeaderValue)>

Returns the headers used by this mock request

Source

pub fn body(&self) -> Option<&[u8]>

Returns the body used by this mock request

Source

pub fn new(method: Method, url: &str) -> Self

Constructs a new mock request

Source

pub fn with_header(self, name: &str, value: &str) -> Self

Convenience method for setting a header

Source

pub fn with_body(self, body: Vec<u8>) -> Self

Method for setting a request body

Source

pub fn from_reader<R: BufRead>(reader: &mut R) -> Result<Self, Box<dyn Error>>

Parse a HTTP request into this mock request object

Source

pub fn write<W: Write>(&self, writer: &mut W) -> Result<(), Box<dyn Error>>

Write out this HTTP request in standard format

Trait Implementations§

Source§

impl ClientRequestLike for MockRequest

Source§

fn compute_digest(&mut self, digest: &dyn HttpDigest) -> Option<String>

Compute the digest using the provided HTTP digest algorithm. If this is not possible, then return None. This may require buffering the request data into memory.
Source§

fn set_header(&mut self, header: HeaderName, value: HeaderValue)

Add a header to the request. This function may be used to set the Date and Digest headers if not already present depending on the configuration. The Authorization header will always be set assuming the message was signed successfully.
Source§

fn host(&self) -> Option<String>

Returns the host for the request (eg. “example.com”, “127.0.0.1:8080”) in case the Host header has not been set explicitly. Note, the correct form of the Host header is <host>:<port> if the port is non-standard for the protocol used (e.g., 443 for an HTTPS URL, and 80 for an HTTP URL). When implementing this trait, do not just read the Host header from the request - this method will only be called when the Host header is not set.
Source§

impl Clone for MockRequest

Source§

fn clone(&self) -> MockRequest

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for MockRequest

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl PartialEq for MockRequest

Source§

fn eq(&self, other: &MockRequest) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl RequestLike for MockRequest

Source§

fn header(&self, header: &Header) -> Option<HeaderValue>

Returns an existing header on the request. This method must reflect changes made be the ClientRequestLike::set_header method, with the possible exception of the Authorization header itself.
Source§

fn has_header(&self, header: &Header) -> bool

Returns true if this request contains a value for the specified header. If this returns true, following requests to header() for the same name must return a value.
Source§

impl ServerRequestLike for &MockRequest

Source§

type Remnant = ()

For some request types, the verification process may be a destructive operation. This associated type can be used to return information that might otherwise be lost.
Source§

fn complete_with_digest( self, digest: &dyn HttpDigest, ) -> (Option<String>, Self::Remnant)

Complete the verification process, indicating that we want to compute a digest of the request body. This may require buffering the whole request body into memory. Read more
Source§

fn complete(self) -> Self::Remnant

Complete the verification process without attempting to compute a digest.
Source§

impl StructuralPartialEq for MockRequest

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CanonicalizeExt for T
where T: RequestLike,

Source§

fn canonicalize( &self, config: &CanonicalizeConfig, ) -> Result<SignatureString, CanonicalizeError>

Compute the canonical representation of this request
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<R> SigningExt for R

Source§

fn sign(&mut self, config: &SigningConfig) -> Result<(), SigningError>

Signs the request in-place according to the provided configuration.
Source§

fn signed(self, config: &SigningConfig) -> Result<Self, SigningError>

Consumes the request and returns it signed according to the provided configuration.
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

impl<T> ErasedDestructor for T
where T: 'static,