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

source

pub fn header_bytes(&self) -> &[u8]

source

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.

source

pub fn as_result_err_str(&self) -> Result<&[u8], &'static str>

A convenience function that just returns a standard Err &str.

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for Twhere T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for Twhere U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T, U> TryFrom<U> for Twhere U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for Twhere U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<V, T> VZip<V> for Twhere V: MultiLane<T>,

§

fn vzip(self) -> V