pub struct Request { /* private fields */ }Expand description
Represents an HTTP request.
Implementations§
Source§impl Request
impl Request
Sourcepub fn new(method: Method, target: RequestTarget) -> Self
pub fn new(method: Method, target: RequestTarget) -> Self
Create a new request using HTTP/1.1 as the default version.
Sourcepub fn builder(method: Method, target: RequestTarget) -> RequestBuilder
pub fn builder(method: Method, target: RequestTarget) -> RequestBuilder
Construct a request builder for incremental configuration.
Sourcepub fn target(&self) -> &RequestTarget
pub fn target(&self) -> &RequestTarget
Return the request target.
Sourcepub fn version(&self) -> HttpVersion
pub fn version(&self) -> HttpVersion
Return the HTTP version.
Sourcepub fn header(&self, name: impl Into<HeaderName>) -> Option<&str>
pub fn header(&self, name: impl Into<HeaderName>) -> Option<&str>
Retrieve the first value for the specified header name.
Sourcepub fn contains_header(&self, name: impl Into<HeaderName>) -> bool
pub fn contains_header(&self, name: impl Into<HeaderName>) -> bool
Returns true if a header with the specified name is present.
Sourcepub fn body_bytes(&self) -> &Bytes
pub fn body_bytes(&self) -> &Bytes
Borrow the buffered body bytes.
Sourcepub fn headers_mut(&mut self) -> &mut Headers
pub fn headers_mut(&mut self) -> &mut Headers
Borrow the header map mutably.
Sourcepub fn set_version(&mut self, version: HttpVersion)
pub fn set_version(&mut self, version: HttpVersion)
Set the HTTP version for the request.
Sourcepub fn set_body_bytes(&mut self, bytes: impl Into<Bytes>)
pub fn set_body_bytes(&mut self, bytes: impl Into<Bytes>)
Replace the buffered body bytes.
Sourcepub fn into_body_bytes(self) -> Bytes
pub fn into_body_bytes(self) -> Bytes
Consume the request and return the buffered body bytes.
Sourcepub fn take_body_bytes(&mut self) -> Bytes
pub fn take_body_bytes(&mut self) -> Bytes
Remove and return the buffered body bytes, leaving an empty buffer.
Sourcepub fn expect_100_continue(&self) -> bool
pub fn expect_100_continue(&self) -> bool
Whether the request includes Expect: 100-continue in its header section.
Sourcepub fn wants_close(&self) -> bool
pub fn wants_close(&self) -> bool
Determine whether the request prefers the connection to close.
Sourcepub fn if_none_match(&self) -> Option<&str>
pub fn if_none_match(&self) -> Option<&str>
Retrieve the If-None-Match header value trimmed of whitespace.
Sourcepub fn if_match(&self) -> Option<&str>
pub fn if_match(&self) -> Option<&str>
Retrieve the If-Match header value trimmed of whitespace.
Sourcepub fn if_unmodified_since(&self) -> Option<SystemTime>
pub fn if_unmodified_since(&self) -> Option<SystemTime>
Retrieve the If-Unmodified-Since value as SystemTime.
Sourcepub fn if_modified_since(&self) -> Option<SystemTime>
pub fn if_modified_since(&self) -> Option<SystemTime>
Retrieve the If-Modified-Since value as SystemTime.