Struct tower_http::decompression::RequestDecompression
source · pub struct RequestDecompression<S> { /* private fields */ }
decompression-br
or decompression-deflate
or decompression-gzip
or decompression-zstd
only.Expand description
Decompresses request bodies and calls its underlying service.
Transparently decompresses request bodies based on the Content-Encoding
header.
When the encoding in the Content-Encoding
header is not accepted an Unsupported Media Type
status code will be returned with the accepted encodings in the Accept-Encoding
header.
Enabling pass-through of unaccepted encodings will not return an Unsupported Media Type
but
will call the underlying service with the unmodified request if the encoding is not supported.
This is disabled by default.
See the module docs for more details.
Implementations§
source§impl<S> RequestDecompression<S>
impl<S> RequestDecompression<S>
sourcepub fn into_inner(self) -> S
pub fn into_inner(self) -> S
Consumes self
, returning the underlying service.
sourcepub fn layer() -> RequestDecompressionLayer
pub fn layer() -> RequestDecompressionLayer
Returns a new Layer
that wraps services with a RequestDecompression
middleware.
sourcepub fn pass_through_unaccepted(self, enabled: bool) -> Self
pub fn pass_through_unaccepted(self, enabled: bool) -> Self
Passes through the request even when the encoding is not supported.
By default pass-through is disabled.
sourcepub fn gzip(self, enable: bool) -> Self
Available on crate feature decompression-gzip
only.
pub fn gzip(self, enable: bool) -> Self
decompression-gzip
only.Sets whether to support gzip encoding.
sourcepub fn deflate(self, enable: bool) -> Self
Available on crate feature decompression-deflate
only.
pub fn deflate(self, enable: bool) -> Self
decompression-deflate
only.Sets whether to support Deflate encoding.
sourcepub fn br(self, enable: bool) -> Self
Available on crate feature decompression-br
only.
pub fn br(self, enable: bool) -> Self
decompression-br
only.Sets whether to support Brotli encoding.
sourcepub fn zstd(self, enable: bool) -> Self
Available on crate feature decompression-zstd
only.
pub fn zstd(self, enable: bool) -> Self
decompression-zstd
only.Sets whether to support Zstd encoding.
sourcepub fn no_gzip(self) -> Self
pub fn no_gzip(self) -> Self
Disables support for gzip encoding.
This method is available even if the gzip
crate feature is disabled.
sourcepub fn no_deflate(self) -> Self
pub fn no_deflate(self) -> Self
Disables support for Deflate encoding.
This method is available even if the deflate
crate feature is disabled.
Trait Implementations§
source§impl<S: Clone> Clone for RequestDecompression<S>
impl<S: Clone> Clone for RequestDecompression<S>
source§fn clone(&self) -> RequestDecompression<S>
fn clone(&self) -> RequestDecompression<S>
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moresource§impl<S: Debug> Debug for RequestDecompression<S>
impl<S: Debug> Debug for RequestDecompression<S>
source§impl<S, ReqBody, ResBody, D> Service<Request<ReqBody>> for RequestDecompression<S>
impl<S, ReqBody, ResBody, D> Service<Request<ReqBody>> for RequestDecompression<S>
§type Response = Response<UnsyncBoxBody<D, Box<dyn Error + Send + Sync>>>
type Response = Response<UnsyncBoxBody<D, Box<dyn Error + Send + Sync>>>
§type Error = <S as Service<Request<DecompressionBody<ReqBody>>>>::Error
type Error = <S as Service<Request<DecompressionBody<ReqBody>>>>::Error
§type Future = RequestDecompressionFuture<<S as Service<Request<DecompressionBody<ReqBody>>>>::Future, ResBody, <S as Service<Request<DecompressionBody<ReqBody>>>>::Error>
type Future = RequestDecompressionFuture<<S as Service<Request<DecompressionBody<ReqBody>>>>::Future, ResBody, <S as Service<Request<DecompressionBody<ReqBody>>>>::Error>
Auto Trait Implementations§
impl<S> RefUnwindSafe for RequestDecompression<S>where
S: RefUnwindSafe,
impl<S> Send for RequestDecompression<S>where
S: Send,
impl<S> Sync for RequestDecompression<S>where
S: Sync,
impl<S> Unpin for RequestDecompression<S>where
S: Unpin,
impl<S> UnwindSafe for RequestDecompression<S>where
S: UnwindSafe,
Blanket Implementations§
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
source§impl<T> Instrument for T
impl<T> Instrument for T
source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
source§impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> PolicyExt for Twhere
T: ?Sized,
source§impl<T, Request> ServiceExt<Request> for T
impl<T, Request> ServiceExt<Request> for T
source§fn ready(&mut self) -> Ready<'_, Self, Request>where
Self: Sized,
fn ready(&mut self) -> Ready<'_, Self, Request>where
Self: Sized,
source§fn ready_and(&mut self) -> Ready<'_, Self, Request>where
Self: Sized,
fn ready_and(&mut self) -> Ready<'_, Self, Request>where
Self: Sized,
ServiceExt::ready
method insteadsource§fn ready_oneshot(self) -> ReadyOneshot<Self, Request>where
Self: Sized,
fn ready_oneshot(self) -> ReadyOneshot<Self, Request>where
Self: Sized,
source§fn oneshot(self, req: Request) -> Oneshot<Self, Request>where
Self: Sized,
fn oneshot(self, req: Request) -> Oneshot<Self, Request>where
Self: Sized,
Service
, calling with the providing request once it is ready.source§fn and_then<F>(self, f: F) -> AndThen<Self, F>
fn and_then<F>(self, f: F) -> AndThen<Self, F>
poll_ready
method. Read moresource§fn map_response<F, Response>(self, f: F) -> MapResponse<Self, F>
fn map_response<F, Response>(self, f: F) -> MapResponse<Self, F>
poll_ready
method. Read moresource§fn map_err<F, Error>(self, f: F) -> MapErr<Self, F>
fn map_err<F, Error>(self, f: F) -> MapErr<Self, F>
poll_ready
method. Read moresource§fn map_result<F, Response, Error>(self, f: F) -> MapResult<Self, F>
fn map_result<F, Response, Error>(self, f: F) -> MapResult<Self, F>
Result<Self::Response, Self::Error>
)
to a different value, regardless of whether the future succeeds or
fails. Read more