Skip to content

Commit f73c13c

Browse files
committed
Correctly override size_hint and is_end_stream for Empty
I noticed this while working on hyperium/tonic#622 as it broke some interop tests.
1 parent e5bd0d1 commit f73c13c

File tree

2 files changed

+10
-2
lines changed

2 files changed

+10
-2
lines changed

CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Unreleased
22

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

55
# 0.4.1 (March 18, 2021)
66

src/empty.rs

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use super::Body;
1+
use super::{Body, SizeHint};
22
use bytes::Buf;
33
use http::HeaderMap;
44
use std::{
@@ -40,6 +40,14 @@ impl<D: Buf> Body for Empty<D> {
4040
) -> Poll<Result<Option<HeaderMap>, Self::Error>> {
4141
Poll::Ready(Ok(None))
4242
}
43+
44+
fn is_end_stream(&self) -> bool {
45+
true
46+
}
47+
48+
fn size_hint(&self) -> SizeHint {
49+
SizeHint::with_exact(0)
50+
}
4351
}
4452

4553
impl<D> fmt::Debug for Empty<D> {

0 commit comments

Comments
 (0)