Struct http_client::HttpResponse
source · pub struct HttpResponse {
pub packet: Vec<u8>,
pub header_length: usize,
pub status_code: u16,
pub reason: String,
}
Expand description
An HttpResponse that has been fully received from a remote server.
TODO: revamp this structure to not store redundant data
Fields§
§packet: Vec<u8>
The actual array of raw bytes received from the server, including all of the headers and body.
header_length: usize
The length of all headers
status_code: u16
The status code, e.g., 200, 404
reason: String
The reason, e.g., “OK”, “File not found”
Implementations§
source§impl HttpResponse
impl HttpResponse
pub fn header_bytes(&self) -> &[u8]
sourcepub fn as_result(&self) -> Result<&[u8], (u16, &str)>
pub fn as_result(&self) -> Result<&[u8], (u16, &str)>
Returns the content of this HttpResponse
as a Result
, in which Ok(content)
is returned
if the status code is 200 (Ok), and Err((status_code, reason))
is returned otherwise.
sourcepub fn as_result_err_str(&self) -> Result<&[u8], &'static str>
pub fn as_result_err_str(&self) -> Result<&[u8], &'static str>
A convenience function that just returns a standard Err &str
.
Auto Trait Implementations§
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