Struct actix_http::Response
source · [−]pub struct Response<B> { /* private fields */ }
Expand description
An HTTP response.
Implementations
sourceimpl 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.
sourceimpl<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 extensions of this response.
sourcepub fn extensions_mut(&mut self) -> RefMut<'_, Extensions>
pub fn extensions_mut(&mut self) -> RefMut<'_, Extensions>
Returns a mutable reference to the extensions of this response.
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,
Returns new response with mapped body.
pub fn map_into_boxed_body(self) -> Response<BoxBody> where
B: MessageBody + 'static,
Trait Implementations
sourceimpl<B> Debug for Response<B> where
B: MessageBody,
impl<B> Debug for Response<B> where
B: MessageBody,
sourceimpl From<&HandshakeError> for Response<BoxBody>
impl From<&HandshakeError> for Response<BoxBody>
sourcefn from(err: &HandshakeError) -> Self
fn from(err: &HandshakeError) -> Self
Converts to this type from the input type.
sourceimpl From<ByteString> for Response<ByteString>
impl From<ByteString> for Response<ByteString>
sourcefn from(val: ByteString) -> Self
fn from(val: ByteString) -> Self
Converts to this type from the input type.
sourceimpl From<HandshakeError> for Response<BoxBody>
impl From<HandshakeError> for Response<BoxBody>
sourcefn from(err: HandshakeError) -> Self
fn from(err: HandshakeError) -> Self
Converts to this type from the input type.
sourceimpl From<Infallible> for Response<BoxBody>
impl From<Infallible> for Response<BoxBody>
sourcefn from(val: Infallible) -> Self
fn from(val: Infallible) -> Self
Converts to this type from the input type.
sourceimpl From<ParseError> for Response<BoxBody>
impl From<ParseError> for Response<BoxBody>
sourcefn from(err: ParseError) -> Self
fn from(err: ParseError) -> Self
Converts to this type from the input type.
sourceimpl<B> From<Response<B>> for ResponseBuilder
impl<B> From<Response<B>> for ResponseBuilder
Convert Response
to a ResponseBuilder
. Body get dropped.
sourcefn from(res: Response<B>) -> ResponseBuilder
fn from(res: Response<B>) -> ResponseBuilder
Converts to this type from the input type.
sourceimpl From<Response<BoxBody>> for DispatchError
impl From<Response<BoxBody>> for DispatchError
sourcefn from(original: Response<BoxBody>) -> DispatchError
fn from(original: Response<BoxBody>) -> DispatchError
Converts to this type from the input type.
sourceimpl From<ResponseBuilder> for Response<BoxBody>
impl From<ResponseBuilder> for Response<BoxBody>
sourcefn from(builder: ResponseBuilder) -> Self
fn from(builder: ResponseBuilder) -> Self
Converts to this type from the input type.
Auto Trait Implementations
impl<B> !RefUnwindSafe for Response<B>
impl<B> !Send for Response<B>
impl<B> !Sync for Response<B>
impl<B> Unpin for Response<B> where
B: Unpin,
impl<B> !UnwindSafe for Response<B>
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
sourceimpl<T> Instrument for T
impl<T> Instrument for T
sourcefn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
sourcefn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
sourceimpl<T> WithSubscriber for T
impl<T> WithSubscriber for T
sourcefn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> where
S: Into<Dispatch>,
fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> where
S: Into<Dispatch>,
Attaches the provided Subscriber
to this type, returning a
WithDispatch
wrapper. Read more
sourcefn with_current_subscriber(self) -> WithDispatch<Self>
fn with_current_subscriber(self) -> WithDispatch<Self>
Attaches the current default Subscriber
to this type, returning a
WithDispatch
wrapper. Read more