pub struct Decompression<S, 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<S> Decompression<S>
impl<S> Decompression<S>
Source§impl<S, M> Decompression<S, M>
impl<S, M> Decompression<S, M>
Sourcepub fn into_inner(self) -> S
pub fn into_inner(self) -> S
Consumes self, returning the underlying service.
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.
When disabled, the request header is forwarded as-is and the layer only advertises
supported encodings if the request already contains an Accept-Encoding header.
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.
When disabled, the request header is forwarded as-is and the layer only advertises
supported encodings if the request already contains an Accept-Encoding header.
Sourcepub fn with_matcher<T>(self, matcher: T) -> Decompression<S, T>
pub fn with_matcher<T>(self, matcher: T) -> Decompression<S, T>
Replaces the request/response decompression matcher.
The matcher runs at request time and may select a second matcher to evaluate the response after the inner service returns. If no response matcher is selected or if the selected response matcher does not match, the response is left compressed even when Rama supports decompressing it.
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.
For relays that decode → modify → re-encode a response (e.g. a MITM HTML rewriter): a truncated upstream body yields a short-but-well-formed client stream rather than an aborted one (RST_STREAM). Off by default; genuine upstream transport errors still propagate.
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.
For relays that decode → modify → re-encode a response (e.g. a MITM HTML rewriter): a truncated upstream body yields a short-but-well-formed client stream rather than an aborted one (RST_STREAM). Off by default; genuine upstream transport errors still propagate.
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<S: Clone, M: Clone> Clone for Decompression<S, M>
impl<S: Clone, M: Clone> Clone for Decompression<S, M>
Source§fn clone(&self) -> Decompression<S, M>
fn clone(&self) -> Decompression<S, 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<S, M, ReqBody, ResBody> Service<Request<ReqBody>> for Decompression<S, M>where
S: Service<Request<ReqBody>, Output = Response<ResBody>, Error: Into<BoxError>>,
M: ServiceMatcher<Request<ReqBody>, ModifiedInput = Request<ReqBody>, Service: ServiceMatcher<Response<ResBody>, ModifiedInput = Response<ResBody>, Service = (), Error: Into<BoxError>>, Error: Into<BoxError>>,
ReqBody: Send + 'static,
ResBody: StreamingBody<Data: Send + 'static, Error: Send + 'static> + Send + 'static,
impl<S, M, ReqBody, ResBody> Service<Request<ReqBody>> for Decompression<S, M>where
S: Service<Request<ReqBody>, Output = Response<ResBody>, Error: Into<BoxError>>,
M: ServiceMatcher<Request<ReqBody>, ModifiedInput = Request<ReqBody>, Service: ServiceMatcher<Response<ResBody>, ModifiedInput = Response<ResBody>, Service = (), Error: Into<BoxError>>, Error: Into<BoxError>>,
ReqBody: Send + 'static,
ResBody: StreamingBody<Data: Send + 'static, Error: Send + 'static> + Send + 'static,
Auto Trait Implementations§
impl<S, M> Freeze for Decompression<S, M>
impl<S, M> RefUnwindSafe for Decompression<S, M>where
S: RefUnwindSafe,
M: RefUnwindSafe,
impl<S, M> Send for Decompression<S, M>
impl<S, M> Sync for Decompression<S, M>
impl<S, M> Unpin for Decompression<S, M>
impl<S, M> UnsafeUnpin for Decompression<S, M>where
S: UnsafeUnpin,
M: UnsafeUnpin,
impl<S, M> UnwindSafe for Decompression<S, M>where
S: UnwindSafe,
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<S, Body> HttpClientExt for S
impl<S, Body> HttpClientExt for S
Source§type ExecuteResponse = Response<Body>
type ExecuteResponse = Response<Body>
execute method.Source§type ExecuteError = <S as Service<Request>>::Error
type ExecuteError = <S as Service<Request>>::Error
execute method.Source§fn get(
&self,
url: impl IntoUrl,
) -> RequestBuilder<'_, S, <S as HttpClientExt>::ExecuteResponse>
fn get( &self, url: impl IntoUrl, ) -> RequestBuilder<'_, S, <S as HttpClientExt>::ExecuteResponse>
GET request to a URL. Read moreSource§fn post(
&self,
url: impl IntoUrl,
) -> RequestBuilder<'_, S, <S as HttpClientExt>::ExecuteResponse>
fn post( &self, url: impl IntoUrl, ) -> RequestBuilder<'_, S, <S as HttpClientExt>::ExecuteResponse>
POST request to a URL. Read moreSource§fn put(
&self,
url: impl IntoUrl,
) -> RequestBuilder<'_, S, <S as HttpClientExt>::ExecuteResponse>
fn put( &self, url: impl IntoUrl, ) -> RequestBuilder<'_, S, <S as HttpClientExt>::ExecuteResponse>
PUT request to a URL. Read moreSource§fn patch(
&self,
url: impl IntoUrl,
) -> RequestBuilder<'_, S, <S as HttpClientExt>::ExecuteResponse>
fn patch( &self, url: impl IntoUrl, ) -> RequestBuilder<'_, S, <S as HttpClientExt>::ExecuteResponse>
PATCH request to a URL. Read moreSource§fn delete(
&self,
url: impl IntoUrl,
) -> RequestBuilder<'_, S, <S as HttpClientExt>::ExecuteResponse>
fn delete( &self, url: impl IntoUrl, ) -> RequestBuilder<'_, S, <S as HttpClientExt>::ExecuteResponse>
DELETE request to a URL. Read moreSource§fn head(
&self,
url: impl IntoUrl,
) -> RequestBuilder<'_, S, <S as HttpClientExt>::ExecuteResponse>
fn head( &self, url: impl IntoUrl, ) -> RequestBuilder<'_, S, <S as HttpClientExt>::ExecuteResponse>
HEAD request to a URL. Read moreSource§fn connect(
&self,
url: impl IntoUrl,
) -> RequestBuilder<'_, S, <S as HttpClientExt>::ExecuteResponse>
fn connect( &self, url: impl IntoUrl, ) -> RequestBuilder<'_, S, <S as HttpClientExt>::ExecuteResponse>
CONNECT request to a URL. Read moreSource§fn request(
&self,
method: Method,
url: impl IntoUrl,
) -> RequestBuilder<'_, S, <S as HttpClientExt>::ExecuteResponse>
fn request( &self, method: Method, url: impl IntoUrl, ) -> RequestBuilder<'_, S, <S as HttpClientExt>::ExecuteResponse>
Source§fn build_from_request<RequestBody>(
&self,
request: Request<RequestBody>,
) -> RequestBuilder<'_, S, <S as HttpClientExt>::ExecuteResponse>
fn build_from_request<RequestBody>( &self, request: Request<RequestBody>, ) -> RequestBuilder<'_, S, <S as HttpClientExt>::ExecuteResponse>
Source§fn execute(
&self,
request: Request,
) -> impl Future<Output = Result<<S as HttpClientExt>::ExecuteResponse, <S as HttpClientExt>::ExecuteError>>
fn execute( &self, request: Request, ) -> impl Future<Output = Result<<S as HttpClientExt>::ExecuteResponse, <S as HttpClientExt>::ExecuteError>>
Request. Read moreSource§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 moreSource§impl<S> IntoEndpointService<(S,)> for S
impl<S> IntoEndpointService<(S,)> for S
type Service = S
Source§fn into_endpoint_service(self) -> <S as IntoEndpointService<(S,)>>::Service
fn into_endpoint_service(self) -> <S as IntoEndpointService<(S,)>>::Service
rama_core::Service.Source§impl<S, State> IntoEndpointServiceWithState<(S,), State> for S
impl<S, State> IntoEndpointServiceWithState<(S,), State> for S
type Service = S
Source§fn into_endpoint_service_with_state(
self,
_state: State,
) -> <S as IntoEndpointServiceWithState<(S,), State>>::Service
fn into_endpoint_service_with_state( self, _state: State, ) -> <S as IntoEndpointServiceWithState<(S,), State>>::Service
rama_core::Service with state.