feat(body): remove Body::is_empty()
BREAKING CHANGE: `Body::is_empty()` is gone. Replace with `Body::is_end_stream()`, from the `Payload` trait.
This commit is contained in:
18
src/body.rs
18
src/body.rs
@@ -224,24 +224,6 @@ impl Body {
|
|||||||
Body::new(Kind::Wrapped(Box::new(mapped)))
|
Body::new(Kind::Wrapped(Box::new(mapped)))
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Returns if this body was constructed via `Body::empty()`.
|
|
||||||
///
|
|
||||||
/// # Note
|
|
||||||
///
|
|
||||||
/// This does **not** detect if the body stream may be at the end, or
|
|
||||||
/// if the stream will not yield any chunks, in all cases. For instance,
|
|
||||||
/// a streaming body using `chunked` encoding is not able to tell if
|
|
||||||
/// there are more chunks immediately.
|
|
||||||
///
|
|
||||||
/// See [`is_end_stream`](Payload::is_end_stream) for a dynamic version.
|
|
||||||
#[inline]
|
|
||||||
pub fn is_empty(&self) -> bool {
|
|
||||||
match self.kind {
|
|
||||||
Kind::Empty => true,
|
|
||||||
_ => false,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
fn new(kind: Kind) -> Body {
|
fn new(kind: Kind) -> Body {
|
||||||
Body {
|
Body {
|
||||||
kind: kind,
|
kind: kind,
|
||||||
|
|||||||
@@ -370,7 +370,7 @@ where C: Connect + Sync + 'static,
|
|||||||
// It won't be ready if there is a body to stream.
|
// It won't be ready if there is a body to stream.
|
||||||
if ver == Ver::Http2 || !pooled.is_pool_enabled() || pooled.is_ready() {
|
if ver == Ver::Http2 || !pooled.is_pool_enabled() || pooled.is_ready() {
|
||||||
drop(pooled);
|
drop(pooled);
|
||||||
} else if !res.body().is_empty() {
|
} else if !res.body().is_end_stream() {
|
||||||
let (delayed_tx, delayed_rx) = oneshot::channel();
|
let (delayed_tx, delayed_rx) = oneshot::channel();
|
||||||
res.body_mut().delayed_eof(delayed_rx);
|
res.body_mut().delayed_eof(delayed_rx);
|
||||||
executor.execute(
|
executor.execute(
|
||||||
|
|||||||
Reference in New Issue
Block a user