Skip to content

Commit

Permalink
Preserve service error type in RequestDecompression
Browse files Browse the repository at this point in the history
  • Loading branch information
rtimush committed May 17, 2023
1 parent d22f200 commit e139528
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 7 deletions.
6 changes: 2 additions & 4 deletions tower-http/src/decompression/request/future.rs
Original file line number Diff line number Diff line change
Expand Up @@ -67,16 +67,14 @@ where
B: Body + Send + 'static,
B::Data: Buf + 'static,
B::Error: Into<BoxError> + 'static,
E: Into<BoxError>,
{
type Output = Result<Response<UnsyncBoxBody<B::Data, BoxError>>, BoxError>;
type Output = Result<Response<UnsyncBoxBody<B::Data, BoxError>>, E>;

fn poll(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Self::Output> {
match self.project().kind.project() {
StateProj::Inner { fut } => fut
.poll(cx)
.map_ok(|res| res.map(|body| body.map_err(Into::into).boxed_unsync()))
.map_err(Into::into),
.map_ok(|res| res.map(|body| body.map_err(Into::into).boxed_unsync())),
StateProj::Unsupported { accept } => {
let res = Response::builder()
.header(
Expand Down
5 changes: 2 additions & 3 deletions tower-http/src/decompression/request/service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,16 +42,15 @@ where
S: Service<Request<DecompressionBody<ReqBody>>, Response = Response<ResBody>>,
ReqBody: Body,
ResBody: Body<Data = D> + Send + 'static,
S::Error: Into<BoxError>,
<ResBody as Body>::Error: Into<BoxError>,
D: Buf + 'static,
{
type Response = Response<UnsyncBoxBody<D, BoxError>>;
type Error = BoxError;
type Error = S::Error;
type Future = ResponseFuture<S::Future, ResBody, S::Error>;

fn poll_ready(&mut self, cx: &mut Context<'_>) -> Poll<Result<(), Self::Error>> {
self.inner.poll_ready(cx).map_err(Into::into)
self.inner.poll_ready(cx)
}

fn call(&mut self, req: Request<ReqBody>) -> Self::Future {
Expand Down

0 comments on commit e139528

Please sign in to comment.