Skip to content

Commit

Permalink
discord non-data frames in Body Stream impl
Browse files Browse the repository at this point in the history
  • Loading branch information
lperlaki committed Mar 16, 2024
1 parent 71ecdf1 commit 4315956
Showing 1 changed file with 9 additions and 8 deletions.
17 changes: 9 additions & 8 deletions crates/s3s/src/http/body.rs
Original file line number Diff line number Diff line change
Expand Up @@ -175,14 +175,15 @@ impl http_body::Body for Body {
impl Stream for Body {
type Item = Result<Bytes, StdError>;

fn poll_next(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Option<Self::Item>> {
match http_body::Body::poll_frame(self, cx) {
Poll::Ready(Some(Ok(f))) if f.is_data() => Poll::Ready(Some(Ok(f.into_data().expect("already checked")))),
Poll::Ready(Some(Ok(f))) if f.is_trailers() => Poll::Ready(None),
Poll::Ready(Some(Ok(_))) => Poll::Ready(Some(Err("unexpected BodyFrame".into()))),
Poll::Ready(Some(Err(err))) => Poll::Ready(Some(Err(err))),
Poll::Ready(None) => Poll::Ready(None),
Poll::Pending => Poll::Pending,
fn poll_next(mut self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Option<Self::Item>> {
loop {
match std::task::ready!(http_body::Body::poll_frame(self.as_mut(), cx)?) {
Some(frame) => match frame.into_data() {
Ok(data) => return Poll::Ready(Some(Ok(data))),
Err(_frame) => continue,
},
None => return Poll::Ready(None),
};
}
}
}
Expand Down

0 comments on commit 4315956

Please sign in to comment.