Skip to content

Commit 00d8030

Browse files
committed
chore(http/classify): upgrade to hyper 1.x
Signed-off-by: katelyn martin <kate@buoyant.io>
1 parent e24b7dd commit 00d8030

File tree

1 file changed

+18
-23
lines changed

1 file changed

+18
-23
lines changed

linkerd/http/classify/src/channel.rs

Lines changed: 18 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
use super::{ClassifyEos, ClassifyResponse};
22
use futures::{prelude::*, ready};
3+
use http_body::Frame;
34
use linkerd_error::Error;
45
use linkerd_stack::{layer, ExtractParam, NewService, Service};
56
use pin_project::{pin_project, pinned_drop};
@@ -215,40 +216,34 @@ where
215216
type Data = B::Data;
216217
type Error = B::Error;
217218

218-
fn poll_data(
219+
fn poll_frame(
219220
self: Pin<&mut Self>,
220221
cx: &mut Context<'_>,
221-
) -> Poll<Option<Result<Self::Data, Self::Error>>> {
222+
) -> Poll<Option<Result<Frame<Self::Data>, Self::Error>>> {
222223
let this = self.project();
223-
match ready!(this.inner.poll_data(cx)) {
224-
None => Poll::Ready(None),
225-
Some(Ok(data)) => Poll::Ready(Some(Ok(data))),
226-
Some(Err(e)) => {
224+
match ready!(this.inner.poll_frame(cx)) {
225+
None => {
226+
// Classify the stream if it has reached a `None`.
227227
if let Some(State { classify, tx }) = this.state.take() {
228-
let _ = tx.try_send(classify.error(&e));
228+
let _ = tx.try_send(classify.eos(None));
229229
}
230-
Poll::Ready(Some(Err(e)))
230+
Poll::Ready(None)
231231
}
232-
}
233-
}
234-
235-
fn poll_trailers(
236-
self: Pin<&mut Self>,
237-
cx: &mut Context<'_>,
238-
) -> Poll<Result<Option<http::HeaderMap>, Self::Error>> {
239-
let this = self.project();
240-
match ready!(this.inner.poll_trailers(cx)) {
241-
Ok(trls) => {
242-
if let Some(State { classify, tx }) = this.state.take() {
243-
let _ = tx.try_send(classify.eos(trls.as_ref()));
232+
Some(Ok(data)) => {
233+
// Classify the stream if this is a trailers frame.
234+
if let trls @ Some(_) = data.trailers_ref() {
235+
if let Some(State { classify, tx }) = this.state.take() {
236+
let _ = tx.try_send(classify.eos(trls));
237+
}
244238
}
245-
Poll::Ready(Ok(trls))
239+
Poll::Ready(Some(Ok(data)))
246240
}
247-
Err(e) => {
241+
Some(Err(e)) => {
242+
// Classify the stream if an error has been encountered.
248243
if let Some(State { classify, tx }) = this.state.take() {
249244
let _ = tx.try_send(classify.error(&e));
250245
}
251-
Poll::Ready(Err(e))
246+
Poll::Ready(Some(Err(e)))
252247
}
253248
}
254249
}

0 commit comments

Comments
 (0)