Skip to content

Commit

Permalink
Correctly override size_hint and is_end_stream for Empty (#42)
Browse files Browse the repository at this point in the history
I noticed this while working on
hyperium/tonic#622 as it broke some interop
tests.
  • Loading branch information
davidpdrsn committed May 8, 2021
1 parent e5bd0d1 commit 7b811bb
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 7b811bb

Please sign in to comment.