pub struct Response {
pub status: u16,
pub reason: &'static str,
pub headers: Vec<(String, String)>,
pub content_type: Option<String>,
pub body: Vec<u8>,
}Expand description
A response to write.
Fields§
§status: u16e.g. 200.
reason: &'static strThe reason phrase (OK, Not Found, …).
headers: Vec<(String, String)>Extra headers beyond Content-Length/Content-Type/Connection,
which write_response always sets itself.
content_type: Option<String>MIME type; None for an empty body (e.g. 204 No Content).
body: Vec<u8>Body bytes.
Implementations§
Source§impl Response
impl Response
Sourcepub fn new(
status: u16,
reason: &'static str,
content_type: &str,
body: Vec<u8>,
) -> Self
pub fn new( status: u16, reason: &'static str, content_type: &str, body: Vec<u8>, ) -> Self
A response with a body and its content type.
Sourcepub fn empty(status: u16, reason: &'static str) -> Self
pub fn empty(status: u16, reason: &'static str) -> Self
A response with no body (204/304/a HEAD answer).
Sourcepub fn with_header(self, name: &str, value: &str) -> Self
pub fn with_header(self, name: &str, value: &str) -> Self
Adds a header.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Response
impl RefUnwindSafe for Response
impl Send for Response
impl Sync for Response
impl Unpin for Response
impl UnsafeUnpin for Response
impl UnwindSafe for Response
Blanket Implementations§
Source§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
Source§impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
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