Struct actix_http::Response
source · pub struct Response<B> { /* private fields */ }
Expand description
An HTTP response.
Implementations§
source§impl Response<BoxBody>
impl Response<BoxBody>
sourcepub fn new(status: StatusCode) -> Self
pub fn new(status: StatusCode) -> Self
Constructs a new response with default body.
sourcepub fn build(status: StatusCode) -> ResponseBuilder
pub fn build(status: StatusCode) -> ResponseBuilder
Constructs a new response builder.
sourcepub fn bad_request() -> Self
pub fn bad_request() -> Self
Constructs a new response with status 400 Bad Request.
sourcepub fn internal_server_error() -> Self
pub fn internal_server_error() -> Self
Constructs a new response with status 500 Internal Server Error.
source§impl<B> Response<B>
impl<B> Response<B>
sourcepub fn with_body(status: StatusCode, body: B) -> Response<B>
pub fn with_body(status: StatusCode, body: B) -> Response<B>
Constructs a new response with given body.
sourcepub fn head(&self) -> &ResponseHead
pub fn head(&self) -> &ResponseHead
Returns a reference to the head of this response.
sourcepub fn head_mut(&mut self) -> &mut ResponseHead
pub fn head_mut(&mut self) -> &mut ResponseHead
Returns a mutable reference to the head of this response.
sourcepub fn status(&self) -> StatusCode
pub fn status(&self) -> StatusCode
Returns the status code of this response.
sourcepub fn status_mut(&mut self) -> &mut StatusCode
pub fn status_mut(&mut self) -> &mut StatusCode
Returns a mutable reference the status code of this response.
sourcepub fn headers_mut(&mut self) -> &mut HeaderMap
pub fn headers_mut(&mut self) -> &mut HeaderMap
Returns a mutable reference to response headers.
sourcepub fn keep_alive(&self) -> bool
pub fn keep_alive(&self) -> bool
Returns true if keep-alive is enabled.
sourcepub fn extensions(&self) -> Ref<'_, Extensions>
pub fn extensions(&self) -> Ref<'_, Extensions>
Returns a reference to the request-local data/extensions container.
sourcepub fn extensions_mut(&mut self) -> RefMut<'_, Extensions>
pub fn extensions_mut(&mut self) -> RefMut<'_, Extensions>
Returns a mutable reference to the request-local data/extensions container.
sourcepub fn into_parts(self) -> (Response<()>, B)
pub fn into_parts(self) -> (Response<()>, B)
Returns split head and body.
§Implementation Notes
Due to internal performance optimizations, the first element of the returned tuple is a
Response
as well but only contains the head of the response this was called on.
sourcepub fn map_body<F, B2>(self, f: F) -> Response<B2>where
F: FnOnce(&mut ResponseHead, B) -> B2,
pub fn map_body<F, B2>(self, f: F) -> Response<B2>where
F: FnOnce(&mut ResponseHead, B) -> B2,
Map the current body type to another using a closure, returning a new response.
Closure receives the response head and the current body type.
sourcepub fn map_into_boxed_body(self) -> Response<BoxBody>where
B: MessageBody + 'static,
pub fn map_into_boxed_body(self) -> Response<BoxBody>where
B: MessageBody + 'static,
Map the current body to a type-erased BoxBody
.
Trait Implementations§
source§impl<B> Debug for Response<B>where
B: MessageBody,
impl<B> Debug for Response<B>where
B: MessageBody,
source§impl From<&HandshakeError> for Response<BoxBody>
Available on crate feature ws
only.
impl From<&HandshakeError> for Response<BoxBody>
ws
only.source§fn from(err: &HandshakeError) -> Self
fn from(err: &HandshakeError) -> Self
source§impl From<HandshakeError> for Response<BoxBody>
Available on crate feature ws
only.
impl From<HandshakeError> for Response<BoxBody>
ws
only.source§fn from(err: HandshakeError) -> Self
fn from(err: HandshakeError) -> Self
source§impl From<Infallible> for Response<BoxBody>
impl From<Infallible> for Response<BoxBody>
source§fn from(val: Infallible) -> Self
fn from(val: Infallible) -> Self
source§impl From<ParseError> for Response<BoxBody>
impl From<ParseError> for Response<BoxBody>
source§fn from(err: ParseError) -> Self
fn from(err: ParseError) -> Self
source§impl<B> From<Response<B>> for ResponseBuilder
impl<B> From<Response<B>> for ResponseBuilder
Convert Response
to a ResponseBuilder
. Body get dropped.