Skip to content

Commit

Permalink
Correctly override size_hint and is_end_stream for Empty (hyper…
Browse files Browse the repository at this point in the history
…ium#42)

I noticed this while working on
hyperium/tonic#622 as it broke some interop
tests.
  • Loading branch information
davidpdrsn authored and Benxiang Ge committed Jul 26, 2021
1 parent 1b938db commit e06871e
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Unreleased

Nothing.
- Correctly override `Body::size_hint` and `Body::is_end_stream` for `Empty`.

# 0.4.1 (March 18, 2021)

Expand Down
10 changes: 9 additions & 1 deletion src/empty.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use super::Body;
use super::{Body, SizeHint};
use bytes::Buf;
use http::HeaderMap;
use std::{
Expand Down Expand Up @@ -40,6 +40,14 @@ impl<D: Buf> Body for Empty<D> {
) -> Poll<Result<Option<HeaderMap>, Self::Error>> {
Poll::Ready(Ok(None))
}

fn is_end_stream(&self) -> bool {
true
}

fn size_hint(&self) -> SizeHint {
SizeHint::with_exact(0)
}
}

impl<D> fmt::Debug for Empty<D> {
Expand Down

0 comments on commit e06871e

Please sign in to comment.