Skip to content

Commit d2eadcb

Browse files
rtimushdavidpdrsn
andauthored
Preserve service error type in RequestDecompression (#368)
* Preserve service error type in RequestDecompression * changelog --------- Co-authored-by: David Pedersen <[email protected]>
1 parent d663cbf commit d2eadcb

File tree

3 files changed

+6
-7
lines changed

3 files changed

+6
-7
lines changed

tower-http/CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1414
## Changed
1515

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

1819
## Removed
1920

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

2728
[#418]: https://github.com/tower-rs/tower-http/pull/418
2829
[#433]: https://github.com/tower-rs/tower-http/pull/433
30+
[#368]: https://github.com/tower-rs/tower-http/pull/368
2931

3032
# 0.4.2 (July 19, 2023)
3133

tower-http/src/decompression/request/future.rs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -67,16 +67,14 @@ where
6767
B: Body + Send + 'static,
6868
B::Data: Buf + 'static,
6969
B::Error: Into<BoxError> + 'static,
70-
E: Into<BoxError>,
7170
{
72-
type Output = Result<Response<UnsyncBoxBody<B::Data, BoxError>>, BoxError>;
71+
type Output = Result<Response<UnsyncBoxBody<B::Data, BoxError>>, E>;
7372

7473
fn poll(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Self::Output> {
7574
match self.project().kind.project() {
7675
StateProj::Inner { fut } => fut
7776
.poll(cx)
78-
.map_ok(|res| res.map(|body| body.map_err(Into::into).boxed_unsync()))
79-
.map_err(Into::into),
77+
.map_ok(|res| res.map(|body| body.map_err(Into::into).boxed_unsync())),
8078
StateProj::Unsupported { accept } => {
8179
let res = Response::builder()
8280
.header(

tower-http/src/decompression/request/service.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,16 +42,15 @@ where
4242
S: Service<Request<DecompressionBody<ReqBody>>, Response = Response<ResBody>>,
4343
ReqBody: Body,
4444
ResBody: Body<Data = D> + Send + 'static,
45-
S::Error: Into<BoxError>,
4645
<ResBody as Body>::Error: Into<BoxError>,
4746
D: Buf + 'static,
4847
{
4948
type Response = Response<UnsyncBoxBody<D, BoxError>>;
50-
type Error = BoxError;
49+
type Error = S::Error;
5150
type Future = ResponseFuture<S::Future, ResBody, S::Error>;
5251

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

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

0 commit comments

Comments
 (0)