pub struct Response { /* private fields */ }
Expand description
Represents an HTTP response
An HTTP response consists of a head and a potentially body.
Platform-specific
- Linux: Headers and status code cannot be changed.
Examples
let response = ResponseBuilder::new()
.status(202)
.mimetype("text/html")
.body("hello!".as_bytes().to_vec())
.unwrap();
Implementations§
source§impl Response
impl Response
sourcepub fn set_status(&mut self, status: StatusCode)
pub fn set_status(&mut self, status: StatusCode)
Sets the status code.
sourcepub fn status(&self) -> StatusCode
pub fn status(&self) -> StatusCode
Returns the StatusCode
.
sourcepub fn set_mimetype(&mut self, mimetype: Option<String>)
pub fn set_mimetype(&mut self, mimetype: Option<String>)
Sets the mimetype.
sourcepub fn headers_mut(&mut self) -> &mut HeaderMap<HeaderValue>
pub fn headers_mut(&mut self) -> &mut HeaderMap<HeaderValue>
Returns a mutable reference to the associated header field map.
sourcepub fn headers(&self) -> &HeaderMap<HeaderValue>
pub fn headers(&self) -> &HeaderMap<HeaderValue>
Returns a reference to the associated header field map.