Skip to content

Commit

Permalink
Preserve service error type in RequestDecompression (#368)
Browse files Browse the repository at this point in the history
* Preserve service error type in RequestDecompression

* changelog

---------

Co-authored-by: David Pedersen <[email protected]>
  • Loading branch information
rtimush and davidpdrsn authored Nov 20, 2023
1 parent d663cbf commit d2eadcb
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 7 deletions.
2 changes: 2 additions & 0 deletions tower-http/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
## Changed

- Bump Minimum Supported Rust Version to 1.66 ([#433])
- Preserve service error type in RequestDecompression ([#368])

## Removed

Expand All @@ -26,6 +27,7 @@ http-range-header to `0.4`

[#418]: https://github.com/tower-rs/tower-http/pull/418
[#433]: https://github.com/tower-rs/tower-http/pull/433
[#368]: https://github.com/tower-rs/tower-http/pull/368

# 0.4.2 (July 19, 2023)

Expand Down
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 d2eadcb

Please sign in to comment.