pub struct Response<'a> { /* private fields */ }
Expand description
Represents a single HTTP-Request
Implementations§
Source§impl<'a> Response<'a>
impl<'a> Response<'a>
Sourcepub fn new(
protocol: &'a str,
status_code: StatusCode,
headers: Headers<'a>,
body: Vec<u8>,
) -> Self
pub fn new( protocol: &'a str, status_code: StatusCode, headers: Headers<'a>, body: Vec<u8>, ) -> Self
Creates a new Response with the given Data as its inital State
Sourcepub fn serialize(&self) -> (Vec<u8>, &[u8])
pub fn serialize(&self) -> (Vec<u8>, &[u8])
Serialzes the Response and returns the Data as a tuple of form (HTTP-Head, HTTP-Body)
Sourcepub fn status_code(&self) -> &StatusCode
pub fn status_code(&self) -> &StatusCode
Returns the StatusCode of the Response
Sourcepub fn add_header<'b, K, V>(&mut self, key: K, value: V)
pub fn add_header<'b, K, V>(&mut self, key: K, value: V)
Adds the Key-Value Pair as a new Header to the Response or replaces the old Value of the Header if it already existed on the Response
Sourcepub fn set_body(&mut self, n_body: Vec<u8>)
pub fn set_body(&mut self, n_body: Vec<u8>)
Replaces the old Body of the Response with the new given Body and updates the Content-Length Header as well with the new Length
Sourcepub fn is_chunked(&self) -> bool
pub fn is_chunked(&self) -> bool
Checks if the Response is send using
Transfer-Encoding: Chunked
Trait Implementations§
impl<'a> StructuralPartialEq for Response<'a>
Auto Trait Implementations§
impl<'a> Freeze for Response<'a>
impl<'a> RefUnwindSafe for Response<'a>
impl<'a> Send for Response<'a>
impl<'a> Sync for Response<'a>
impl<'a> Unpin for Response<'a>
impl<'a> UnwindSafe for Response<'a>
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