Struct ntex::http::Response

source ·
pub struct Response<B = Body> { /* private fields */ }
Expand description

An HTTP Response

Implementations§

source§

impl Response

source

pub fn Ok() -> ResponseBuilder

source

pub fn Created() -> ResponseBuilder

source

pub fn Accepted() -> ResponseBuilder

source

pub fn NonAuthoritativeInformation() -> ResponseBuilder

source

pub fn NoContent() -> ResponseBuilder

source

pub fn ResetContent() -> ResponseBuilder

source

pub fn PartialContent() -> ResponseBuilder

source

pub fn MultiStatus() -> ResponseBuilder

source

pub fn AlreadyReported() -> ResponseBuilder

source

pub fn MultipleChoices() -> ResponseBuilder

source

pub fn MovedPermanently() -> ResponseBuilder

source

pub fn Found() -> ResponseBuilder

source

pub fn SeeOther() -> ResponseBuilder

source

pub fn NotModified() -> ResponseBuilder

source

pub fn UseProxy() -> ResponseBuilder

source

pub fn TemporaryRedirect() -> ResponseBuilder

source

pub fn PermanentRedirect() -> ResponseBuilder

source

pub fn BadRequest() -> ResponseBuilder

source

pub fn NotFound() -> ResponseBuilder

source

pub fn Unauthorized() -> ResponseBuilder

source

pub fn PaymentRequired() -> ResponseBuilder

source

pub fn Forbidden() -> ResponseBuilder

source

pub fn MethodNotAllowed() -> ResponseBuilder

source

pub fn NotAcceptable() -> ResponseBuilder

source

pub fn ProxyAuthenticationRequired() -> ResponseBuilder

source

pub fn RequestTimeout() -> ResponseBuilder

source

pub fn Conflict() -> ResponseBuilder

source

pub fn Gone() -> ResponseBuilder

source

pub fn LengthRequired() -> ResponseBuilder

source

pub fn PreconditionFailed() -> ResponseBuilder

source

pub fn PreconditionRequired() -> ResponseBuilder

source

pub fn PayloadTooLarge() -> ResponseBuilder

source

pub fn UriTooLong() -> ResponseBuilder

source

pub fn UnsupportedMediaType() -> ResponseBuilder

source

pub fn RangeNotSatisfiable() -> ResponseBuilder

source

pub fn ExpectationFailed() -> ResponseBuilder

source

pub fn UnprocessableEntity() -> ResponseBuilder

source

pub fn TooManyRequests() -> ResponseBuilder

source

pub fn InternalServerError() -> ResponseBuilder

source

pub fn NotImplemented() -> ResponseBuilder

source

pub fn BadGateway() -> ResponseBuilder

source

pub fn ServiceUnavailable() -> ResponseBuilder

source

pub fn GatewayTimeout() -> ResponseBuilder

source

pub fn VersionNotSupported() -> ResponseBuilder

source

pub fn VariantAlsoNegotiates() -> ResponseBuilder

source

pub fn InsufficientStorage() -> ResponseBuilder

source

pub fn LoopDetected() -> ResponseBuilder

source§

impl Response<Body>

source

pub fn build(status: StatusCode) -> ResponseBuilder

Create http response builder with specific status.

source

pub fn build_from<T: Into<ResponseBuilder>>(source: T) -> ResponseBuilder

Create http response builder

source

pub fn new(status: StatusCode) -> Response

Constructs a response

source

pub fn into_body<B>(self) -> Response<B>

Convert response to response with body

source§

impl<B> Response<B>

source

pub fn with_body(status: StatusCode, body: B) -> Response<B>

Constructs a response with body

source

pub fn head(&self) -> &ResponseHead

Http message part of the response

source

pub fn head_mut(&mut self) -> &mut ResponseHead

Mutable reference to a http message part of the response

source

pub fn status(&self) -> StatusCode

Get the response status code

source

pub fn status_mut(&mut self) -> &mut StatusCode

Set the StatusCode for this response

source

pub fn headers(&self) -> &HeaderMap

Get the headers from the response

source

pub fn headers_mut(&mut self) -> &mut HeaderMap

Get a mutable reference to the headers

source

pub fn cookies(&self) -> CookieIter<'_>

Get an iterator for the cookies set by this response

Add a cookie to this response

Remove all cookies with the given name from this response. Returns the number of cookies removed.

source

pub fn upgrade(&self) -> bool

Connection upgrade status

source

pub fn keep_alive(&self) -> bool

Keep-alive status for this connection

source

pub fn extensions(&self) -> Ref<'_, Extensions>

Responses extensions

source

pub fn extensions_mut(&self) -> RefMut<'_, Extensions>

Mutable reference to a the response’s extensions

source

pub fn body(&self) -> &ResponseBody<B>

Get body of this response

source

pub fn set_body<B2>(self, body: B2) -> Response<B2>

Set a body

source

pub fn into_parts(self) -> (Response<()>, ResponseBody<B>)

Split response and body

source

pub fn drop_body(self) -> Response<()>

Drop request’s body

source

pub fn map_body<F, B2>(self, f: F) -> Response<B2>
where F: FnOnce(&mut ResponseHead, ResponseBody<B>) -> ResponseBody<B2>,

Set a body and return previous body value

source

pub fn take_body(&mut self) -> ResponseBody<B>

Extract response body

Trait Implementations§

source§

impl<B> BodyEncoding for HttpResponse<B>

source§

fn get_encoding(&self) -> Option<ContentEncoding>

Get content encoding
source§

fn encoding(&mut self, encoding: ContentEncoding) -> &mut Self

Set content encoding
source§

impl<B: MessageBody> Debug for Response<B>

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl From<&'static [u8]> for Response

source§

fn from(val: &'static [u8]) -> Self

Converts to this type from the input type.
source§

impl<'a> From<&'a String> for Response

source§

fn from(val: &'a String) -> Self

Converts to this type from the input type.
source§

impl From<&'static str> for Response

source§

fn from(val: &'static str) -> Self

Converts to this type from the input type.
source§

impl From<Bytes> for Response

source§

fn from(val: Bytes) -> Self

Converts to this type from the input type.
source§

impl From<BytesMut> for Response

source§

fn from(val: BytesMut) -> Self

Converts to this type from the input type.
source§

impl<B> From<Response<B>> for ResponseBuilder

Convert Response to a ResponseBuilder. Body get dropped.

source§

fn from(res: Response<B>) -> ResponseBuilder

Converts to this type from the input type.
source§

impl From<ResponseBuilder> for Response

source§

fn from(builder: ResponseBuilder) -> Self

Converts to this type from the input type.
source§

impl<I: Into<Response>, E> From<Result<I, E>> for Response
where E: ResponseError + Debug,

Helper converters

source§

fn from(res: Result<I, E>) -> Self

Converts to this type from the input type.
source§

impl From<String> for Response

source§

fn from(val: String) -> Self

Converts to this type from the input type.
source§

impl<T: ResponseError> From<T> for Response

source§

fn from(err: T) -> Response

Converts to this type from the input type.
source§

impl From<WebResponse> for Response<Body>

source§

fn from(res: WebResponse) -> Response<Body>

Converts to this type from the input type.
source§

impl<Err: ErrorRenderer> Responder<Err> for Response

source§

async fn respond_to(self, _: &HttpRequest) -> Response

Convert itself to http response.
source§

fn with_status(self, status: StatusCode) -> CustomResponder<Self, Err>
where Self: Sized,

Override a status code for a Responder. Read more
source§

fn with_header<K, V>(self, key: K, value: V) -> CustomResponder<Self, Err>

Add header to the Responder’s response. Read more

Auto Trait Implementations§

§

impl<B> Freeze for Response<B>
where B: Freeze,

§

impl<B = Body> !RefUnwindSafe for Response<B>

§

impl<B = Body> !Send for Response<B>

§

impl<B = Body> !Sync for Response<B>

§

impl<B> Unpin for Response<B>
where B: Unpin,

§

impl<B = Body> !UnwindSafe for Response<B>

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T> Instrument for T

source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> Same for T

source§

type Output = T

Should always be Self
source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

source§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
source§

impl<T> WithSubscriber for T

source§

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
source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more