pub struct Response<'a, 'headers> {
pub status: u16,
pub reason: &'a str,
pub headers: &'headers [Header<'a>],
pub body: &'a [u8],
}Expand description
A parsed http response
Fields§
§status: u16The status code of the response
reason: &'a strThe reason phrase of the response or an empty string if it doesn’t exist
headers: &'headers [Header<'a>]The HTTP response headers
body: &'a [u8]The body of the response or an empty slice if there is no body
Implementations§
Source§impl<'a, 'headers> Response<'a, 'headers>
impl<'a, 'headers> Response<'a, 'headers>
Sourcepub fn new(
status: u16,
reason: &'a str,
headers: &'headers [Header<'a>],
body: &'a [u8],
) -> Response<'a, 'headers>
pub fn new( status: u16, reason: &'a str, headers: &'headers [Header<'a>], body: &'a [u8], ) -> Response<'a, 'headers>
Construct a new Response from its parts.
Use an empty &str to create a Respose with no reason phrase
Use an empty &str to create a Respose with no body
Sourcepub fn as_bytes(&self) -> Vec<u8> ⓘ
pub fn as_bytes(&self) -> Vec<u8> ⓘ
The byte representation of the Response transmittible over wire
Sourcepub fn parse(
slice: &'a [u8],
header_buf: &'headers mut [Header<'a>],
) -> Result<Response<'a, 'headers>>
pub fn parse( slice: &'a [u8], header_buf: &'headers mut [Header<'a>], ) -> Result<Response<'a, 'headers>>
Parses the bytes of an HTTP response into a Response
It parses headers into the header_buf you pass, if there is more headers than the length of the buffer you pass, an Err(Error::TooManyHeaders) is returned
Trait Implementations§
impl<'a, 'headers> Eq for Response<'a, 'headers>
impl<'a, 'headers> StructuralPartialEq for Response<'a, 'headers>
Auto Trait Implementations§
impl<'a, 'headers> Freeze for Response<'a, 'headers>
impl<'a, 'headers> RefUnwindSafe for Response<'a, 'headers>
impl<'a, 'headers> Send for Response<'a, 'headers>
impl<'a, 'headers> Sync for Response<'a, 'headers>
impl<'a, 'headers> Unpin for Response<'a, 'headers>
impl<'a, 'headers> UnwindSafe for Response<'a, 'headers>
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