pub struct HttpResponse {
pub status: u16,
pub reason: Bytes,
pub version: HttpVersion,
pub headers: Vec<(Bytes, Bytes)>,
pub body: Bytes,
}Available on crate feature
http only.Expand description
Parsed HTTP/1.x response.
Fields§
§status: u16§reason: BytesReason phrase from the status line.
version: HttpVersion§headers: Vec<(Bytes, Bytes)>§body: BytesImplementations§
Source§impl HttpResponse
impl HttpResponse
Sourcepub fn reason_str(&self) -> Option<&str>
pub fn reason_str(&self) -> Option<&str>
Reason phrase as a UTF-8 &str (e.g. "OK").
Sourcepub fn content_type(&self) -> Option<&str>
pub fn content_type(&self) -> Option<&str>
Content-Type: header value as UTF-8.
Sourcepub fn content_length(&self) -> Option<u64>
pub fn content_length(&self) -> Option<u64>
Content-Length: header value parsed as u64. None
if absent, non-UTF-8, or non-numeric.
All Set-Cookie: header values as UTF-8, in observation
order. HTTP/1.x servers can set multiple cookies via
repeated headers.
Sourcepub fn status_class(&self) -> Option<u8>
pub fn status_class(&self) -> Option<u8>
Status class — status / 100. Returns None only if the
status falls outside [100, 599]. New in 0.10.0.
Sourcepub fn is_success(&self) -> bool
pub fn is_success(&self) -> bool
2xx predicate. New in 0.10.0.
Sourcepub fn is_redirect(&self) -> bool
pub fn is_redirect(&self) -> bool
3xx predicate. New in 0.10.0.
Sourcepub fn is_client_error(&self) -> bool
pub fn is_client_error(&self) -> bool
4xx predicate. New in 0.10.0.
Sourcepub fn is_server_error(&self) -> bool
pub fn is_server_error(&self) -> bool
5xx predicate. New in 0.10.0.
Sourcepub fn header(&self, name: &str) -> Option<&[u8]>
pub fn header(&self, name: &str) -> Option<&[u8]>
First match (case-insensitive) for an arbitrary header.
Mirror of HttpRequest::header.
Sourcepub fn headers_all<'a>(
&'a self,
name: &'a str,
) -> impl Iterator<Item = &'a [u8]> + 'a
pub fn headers_all<'a>( &'a self, name: &'a str, ) -> impl Iterator<Item = &'a [u8]> + 'a
All matches (case-insensitive) for an arbitrary header.
Mirror of HttpRequest::headers_all.
Trait Implementations§
Source§impl Clone for HttpResponse
impl Clone for HttpResponse
Source§fn clone(&self) -> HttpResponse
fn clone(&self) -> HttpResponse
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for HttpResponse
impl Debug for HttpResponse
Source§impl<'de> Deserialize<'de> for HttpResponse
impl<'de> Deserialize<'de> for HttpResponse
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Auto Trait Implementations§
impl !Freeze for HttpResponse
impl RefUnwindSafe for HttpResponse
impl Send for HttpResponse
impl Sync for HttpResponse
impl Unpin for HttpResponse
impl UnsafeUnpin for HttpResponse
impl UnwindSafe for HttpResponse
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more