#[non_exhaustive]pub struct HttpResponse {
pub status: u16,
pub headers: Vec<(String, String)>,
pub body: Vec<u8>,
}Expand description
What a client got back.
Fields (Non-exhaustive)§
This struct is marked as non-exhaustive
Non-exhaustive structs could have additional fields added in future. Therefore, non-exhaustive structs cannot be constructed in external crates using the traditional
Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.status: u16The HTTP status code.
headers: Vec<(String, String)>Response headers, in the order received.
body: Vec<u8>The raw body. Empty rather than absent, as HTTP has it.
Implementations§
Source§impl HttpResponse
impl HttpResponse
Sourcepub fn json(status: u16, body: &Value) -> Self
pub fn json(status: u16, body: &Value) -> Self
A response that carries a JSON body, for tests and fakes.
Sourcepub fn header(&self, name: &str) -> Option<&str>
pub fn header(&self, name: &str) -> Option<&str>
The first value of name, matched case-insensitively.
Sourcepub fn body_as_json(&self) -> Option<Value>
pub fn body_as_json(&self) -> Option<Value>
The body parsed as JSON, or None when it is not JSON.
A runtime expression may point into a response body, and only a parsed body can be pointed into.
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 Default for HttpResponse
impl Default for HttpResponse
Source§fn default() -> HttpResponse
fn default() -> HttpResponse
Returns the “default value” for a type. Read more
impl Eq for HttpResponse
Source§impl PartialEq for HttpResponse
impl PartialEq for HttpResponse
impl StructuralPartialEq for HttpResponse
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