Skip to content

Commit b07b0d8

Browse files
authored
chore(proxy/http): replace hyper::Body with BoxBody (#3480)
`UpgradeResponseBody` currently wraps a `hyper::Body`. this type is removed in hyper 1.0. this commit replaces this with a generic `B`-typed body. see #3479, which performs the same change in `linkerd-http-upgrade`. see linkerd/linkerd2#8733 for more information on upgrading to hyper 1.0. Signed-off-by: katelyn martin <[email protected]>
1 parent 612bf67 commit b07b0d8

File tree

1 file changed

+13
-6
lines changed

1 file changed

+13
-6
lines changed

linkerd/proxy/http/src/orig_proto.rs

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,9 @@ pub struct DowngradedH2Error(h2::Reason);
2626

2727
#[pin_project::pin_project]
2828
#[derive(Debug, Default)]
29-
pub struct UpgradeResponseBody {
30-
inner: hyper::Body,
29+
pub struct UpgradeResponseBody<B> {
30+
#[pin]
31+
inner: B,
3132
}
3233

3334
/// Downgrades HTTP2 requests that were previousl upgraded to their original
@@ -197,8 +198,12 @@ fn test_downgrade_h2_error() {
197198

198199
// === impl UpgradeResponseBody ===
199200

200-
impl Body for UpgradeResponseBody {
201-
type Data = bytes::Bytes;
201+
impl<B> Body for UpgradeResponseBody<B>
202+
where
203+
B: Body + Unpin,
204+
B::Error: std::error::Error + Send + Sync + 'static,
205+
{
206+
type Data = B::Data;
202207
type Error = Error;
203208

204209
#[inline]
@@ -210,7 +215,8 @@ impl Body for UpgradeResponseBody {
210215
self: Pin<&mut Self>,
211216
cx: &mut Context<'_>,
212217
) -> Poll<Option<Result<Self::Data, Self::Error>>> {
213-
Pin::new(self.project().inner)
218+
self.project()
219+
.inner
214220
.poll_data(cx)
215221
.map_err(downgrade_h2_error)
216222
}
@@ -219,7 +225,8 @@ impl Body for UpgradeResponseBody {
219225
self: Pin<&mut Self>,
220226
cx: &mut Context<'_>,
221227
) -> Poll<Result<Option<http::HeaderMap>, Self::Error>> {
222-
Pin::new(self.project().inner)
228+
self.project()
229+
.inner
223230
.poll_trailers(cx)
224231
.map_err(downgrade_h2_error)
225232
}

0 commit comments

Comments
 (0)