pub struct DecompressionLayer<M = DefaultDecompressionMatcher> { /* private fields */ }compression only.Expand description
Decompresses response bodies of the underlying service.
This adds the Accept-Encoding header to requests and transparently decompresses response
bodies based on the Content-Encoding header.
See the module docs for more details.
Implementations§
Source§impl<M> DecompressionLayer<M>
impl<M> DecompressionLayer<M>
Sourcepub fn with_insert_accept_encoding_header(self, insert: bool) -> Self
pub fn with_insert_accept_encoding_header(self, insert: bool) -> Self
Sets whether the layer inserts Accept-Encoding into requests when it is absent.
By default it is true.
Sourcepub fn set_insert_accept_encoding_header(&mut self, insert: bool) -> &mut Self
pub fn set_insert_accept_encoding_header(&mut self, insert: bool) -> &mut Self
Sets whether the layer inserts Accept-Encoding into requests when it is absent.
By default it is true.
Sourcepub fn with_matcher<T>(self, matcher: T) -> DecompressionLayer<T>
pub fn with_matcher<T>(self, matcher: T) -> DecompressionLayer<T>
Replaces the request/response decompression matcher.
The default matcher DefaultDecompressionMatcher
matches any response which has a response payload to be decompressed.
Sourcepub fn with_tolerate_decode_errors(self, tolerate: bool) -> Self
pub fn with_tolerate_decode_errors(self, tolerate: bool) -> Self
End a response body cleanly on a mid-stream decode error (after some data decoded) instead of surfacing the error. Off by default.
Intended for relays that decode → modify → re-encode a response (e.g. a MITM HTML rewriter): a truncated upstream body then yields a short-but- well-formed client stream rather than an aborted one.
Sourcepub fn set_tolerate_decode_errors(&mut self, tolerate: bool) -> &mut Self
pub fn set_tolerate_decode_errors(&mut self, tolerate: bool) -> &mut Self
End a response body cleanly on a mid-stream decode error (after some data decoded) instead of surfacing the error. Off by default.
Intended for relays that decode → modify → re-encode a response (e.g. a MITM HTML rewriter): a truncated upstream body then yields a short-but- well-formed client stream rather than an aborted one.
Sourcepub fn set_gzip(&mut self, enable: bool) -> &mut Self
pub fn set_gzip(&mut self, enable: bool) -> &mut Self
Sets whether to request the gzip encoding.
Sourcepub fn with_deflate(self, enable: bool) -> Self
pub fn with_deflate(self, enable: bool) -> Self
Sets whether to request the Deflate encoding.
Sourcepub fn set_deflate(&mut self, enable: bool) -> &mut Self
pub fn set_deflate(&mut self, enable: bool) -> &mut Self
Sets whether to request the Deflate encoding.
Trait Implementations§
Source§impl<M: Clone> Clone for DecompressionLayer<M>
impl<M: Clone> Clone for DecompressionLayer<M>
Source§fn clone(&self) -> DecompressionLayer<M>
fn clone(&self) -> DecompressionLayer<M>
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl<M: Debug> Debug for DecompressionLayer<M>
impl<M: Debug> Debug for DecompressionLayer<M>
Source§impl<M: Default> Default for DecompressionLayer<M>
impl<M: Default> Default for DecompressionLayer<M>
Source§impl<S, M> Layer<S> for DecompressionLayer<M>where
M: Clone,
impl<S, M> Layer<S> for DecompressionLayer<M>where
M: Clone,
Source§type Service = Decompression<S, M>
type Service = Decompression<S, M>
Source§fn layer(&self, service: S) -> Self::Service
fn layer(&self, service: S) -> Self::Service
Source§fn into_layer(self, inner: S) -> Self::Service
fn into_layer(self, inner: S) -> Self::Service
layer but consuming self after the service was created. Read moreAuto Trait Implementations§
impl<M> Freeze for DecompressionLayer<M>where
M: Freeze,
impl<M> RefUnwindSafe for DecompressionLayer<M>where
M: RefUnwindSafe,
impl<M> Send for DecompressionLayer<M>where
M: Send,
impl<M> Sync for DecompressionLayer<M>where
M: Sync,
impl<M> Unpin for DecompressionLayer<M>where
M: Unpin,
impl<M> UnsafeUnpin for DecompressionLayer<M>where
M: UnsafeUnpin,
impl<M> UnwindSafe for DecompressionLayer<M>where
M: UnwindSafe,
Blanket Implementations§
Source§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
Source§impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> FutureExt for T
impl<T> FutureExt for T
Source§fn with_context(self, otel_cx: Context) -> WithContext<Self>
fn with_context(self, otel_cx: Context) -> WithContext<Self>
Source§fn with_current_context(self) -> WithContext<Self>
fn with_current_context(self) -> WithContext<Self>
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> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more