pub struct HttpResponse {
pub version: String,
pub status: u16,
pub status_text: String,
pub headers: Vec<(String, String)>,
pub body: String,
pub elapsed_ms: u128,
pub url: String,
}Expand description
HTTP Response
Fields§
§version: StringHTTP Version
status: u16Response status code
status_text: StringResponse status text
headers: Vec<(String, String)>Response headers
body: StringResponse body as string
elapsed_ms: u128Response body as bytes (for binary data) Request duration in milliseconds
url: StringFinal URL (after redirects)
Implementations§
Source§impl HttpResponse
impl HttpResponse
Sourcepub fn is_success(&self) -> bool
pub fn is_success(&self) -> bool
Check if the response status is successful (2xx)
Sourcepub fn is_redirect(&self) -> bool
pub fn is_redirect(&self) -> bool
Check if the response status is a redirect (3xx)
Sourcepub fn is_client_error(&self) -> bool
pub fn is_client_error(&self) -> bool
Check if the response status is a client error (4xx)
Sourcepub fn is_server_error(&self) -> bool
pub fn is_server_error(&self) -> bool
Check if the response status is a server error (5xx)
Sourcepub fn json<T: DeserializeOwned>(&self) -> Result<T, Error>
pub fn json<T: DeserializeOwned>(&self) -> Result<T, Error>
Try to parse the response body as JSON
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 · Source§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§
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