mirror of
https://github.com/openharmony/third_party_rust_http-body.git
synced 2026-07-01 20:24:01 -04:00
Make default is_end_stream pessimistically return false (#15)
* Make default is_end_stream pessimistically return false * Fix test to ensure no size hint will default to an ended stream Signed-off-by: Lucio Franco <luciofranco14@gmail.com>
This commit is contained in:
committed by
Lucio Franco
parent
cfdb1f3a5a
commit
f4694c7e82
+1
-6
@@ -66,12 +66,7 @@ pub trait Body {
|
||||
/// A return value of `false` **does not** guarantee that a value will be
|
||||
/// returned from `poll_stream` or `poll_trailers`.
|
||||
fn is_end_stream(&self) -> bool {
|
||||
let size_hint = self.size_hint();
|
||||
|
||||
size_hint
|
||||
.upper()
|
||||
.map(|upper| upper == 0 && upper == size_hint.lower())
|
||||
.unwrap_or(false)
|
||||
false
|
||||
}
|
||||
|
||||
/// Returns the bounds on the remaining length of the stream.
|
||||
|
||||
@@ -37,7 +37,7 @@ fn is_end_stream_true() {
|
||||
(Some(123), None, false),
|
||||
(Some(0), Some(123), false),
|
||||
(Some(123), Some(123), false),
|
||||
(Some(0), Some(0), true),
|
||||
(Some(0), Some(0), false),
|
||||
];
|
||||
|
||||
for &(lower, upper, is_end_stream) in &combos {
|
||||
|
||||
Reference in New Issue
Block a user