Skip to main content

Request

Struct Request 

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

Represents an HTTP request.

Implementations§

Source§

impl Request

Source

pub fn new(method: Method, target: RequestTarget) -> Self

Create a new request using HTTP/1.1 as the default version.

Source

pub fn builder(method: Method, target: RequestTarget) -> RequestBuilder

Construct a request builder for incremental configuration.

Source

pub fn method(&self) -> &Method

Return the request method.

Source

pub fn target(&self) -> &RequestTarget

Return the request target.

Source

pub fn version(&self) -> HttpVersion

Return the HTTP version.

Source

pub fn headers(&self) -> &Headers

Borrow the header map.

Source

pub fn header(&self, name: impl Into<HeaderName>) -> Option<&str>

Retrieve the first value for the specified header name.

Source

pub fn contains_header(&self, name: impl Into<HeaderName>) -> bool

Returns true if a header with the specified name is present.

Source

pub fn body(&self) -> &Body

Borrow the body representation.

Source

pub fn body_bytes(&self) -> &Bytes

Borrow the buffered body bytes.

Source

pub fn headers_mut(&mut self) -> &mut Headers

Borrow the header map mutably.

Source

pub fn set_version(&mut self, version: HttpVersion)

Set the HTTP version for the request.

Source

pub fn set_body(&mut self, body: Body)

Set the body representation.

Source

pub fn set_body_bytes(&mut self, bytes: impl Into<Bytes>)

Replace the buffered body bytes.

Source

pub fn into_body_bytes(self) -> Bytes

Consume the request and return the buffered body bytes.

Source

pub fn take_body_bytes(&mut self) -> Bytes

Remove and return the buffered body bytes, leaving an empty buffer.

Source

pub fn expect_100_continue(&self) -> bool

Whether the request includes Expect: 100-continue in its header section.

Source

pub fn wants_close(&self) -> bool

Determine whether the request prefers the connection to close.

Source

pub fn if_none_match(&self) -> Option<&str>

Retrieve the If-None-Match header value trimmed of whitespace.

Source

pub fn if_match(&self) -> Option<&str>

Retrieve the If-Match header value trimmed of whitespace.

Source

pub fn if_unmodified_since(&self) -> Option<SystemTime>

Retrieve the If-Unmodified-Since value as SystemTime.

Source

pub fn if_modified_since(&self) -> Option<SystemTime>

Retrieve the If-Modified-Since value as SystemTime.

Trait Implementations§

Source§

impl Clone for Request

Source§

fn clone(&self) -> Request

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

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

Performs copy-assignment from source. Read more
Source§

impl Debug for Request

Source§

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

Formats the value using the given formatter. Read more

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> 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> 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 = !

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<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