pub struct HttpResponse {
pub version: String,
pub status_code: u16,
pub reason: String,
pub headers: BTreeMap<String, String>,
pub body: Vec<u8>,
}Expand description
An HTTP response.
Fields§
§version: StringHTTP version string (e.g. “HTTP/1.1”)
status_code: u16Status code (e.g. 200, 404)
reason: StringReason phrase (e.g. “OK”, “Not Found”)
headers: BTreeMap<String, String>Response headers (lowercase key -> value)
body: Vec<u8>Response body
Implementations§
Source§impl HttpResponse
impl HttpResponse
Sourcepub fn is_redirect(&self) -> bool
pub fn is_redirect(&self) -> bool
Check if this is a redirect status (301, 302, 307, 308).
Sourcepub fn redirect_location(&self) -> Option<&String>
pub fn redirect_location(&self) -> Option<&String>
Get the Location header for redirects.
Sourcepub fn is_keep_alive(&self) -> bool
pub fn is_keep_alive(&self) -> bool
Check if the connection should be kept alive.
Sourcepub fn content_type(&self) -> Option<&String>
pub fn content_type(&self) -> Option<&String>
Get the Content-Type header value.
Sourcepub fn content_length(&self) -> Option<usize>
pub fn content_length(&self) -> Option<usize>
Get the Content-Length value if present.
Sourcepub fn content_encoding(&self) -> ContentEncoding
pub fn content_encoding(&self) -> ContentEncoding
Get Content-Encoding header value.
Sourcepub fn body_as_str(&self) -> Option<&str>
pub fn body_as_str(&self) -> Option<&str>
Return the body interpreted as a UTF-8 string, if valid.
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§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreAuto Trait Implementations§
impl Freeze for HttpResponse
impl RefUnwindSafe for HttpResponse
impl Send for HttpResponse
impl Sync for HttpResponse
impl Unpin for HttpResponse
impl UnwindSafe for HttpResponse
Blanket Implementations§
§impl<T> Any for Twhere
T: 'static + ?Sized,
impl<T> Any for Twhere
T: 'static + ?Sized,
§impl<T> Borrow<T> for Twhere
T: ?Sized,
impl<T> Borrow<T> for Twhere
T: ?Sized,
§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§unsafe fn clone_to_uninit(&self, dest: *mut u8)
unsafe fn clone_to_uninit(&self, dest: *mut u8)
🔬This is a nightly-only experimental API. (
clone_to_uninit)