diff --git a/src/body.rs b/src/body.rs index 5540bfb1..1c19d942 100644 --- a/src/body.rs +++ b/src/body.rs @@ -290,7 +290,8 @@ impl Body { .map(|async| { async.map(|opt| { opt.map(|bytes| { - Chunk::h2(bytes, h2.release_capacity()) + let _ = h2.release_capacity().release_capacity(bytes.len()); + Chunk::from(bytes) }) }) }) diff --git a/src/chunk.rs b/src/chunk.rs index c8e34426..e0f9e33d 100644 --- a/src/chunk.rs +++ b/src/chunk.rs @@ -1,23 +1,16 @@ use std::fmt; use bytes::{Buf, Bytes}; -use h2::ReleaseCapacity; /// A piece of a message body. /// -/// These are returned by [`Body`](::Body). It is an efficient buffer type, -/// and wraps auto-management of flow control in the case of HTTP2 messages. +/// These are returned by [`Body`](::Body). It is an efficient buffer type. /// /// A `Chunk` can be easily created by many of Rust's standard types that /// represent a collection of bytes, using `Chunk::from`. pub struct Chunk { /// The buffer of bytes making up this body. bytes: Bytes, - /// A possible HTTP2 marker to ensure we release window capacity. - /// - /// This version just automatically releases all capacity when `Chunk` - /// is dropped. - _flow_control: Option, } // An unexported type to prevent locking `Chunk::into_iter()` to `Bytes::into_iter()`. @@ -26,29 +19,8 @@ pub struct IntoIter { inner: ::IntoIter, } -struct AutoRelease { - cap: usize, - release: ReleaseCapacity, -} - -impl Drop for AutoRelease { - fn drop(&mut self) { - let _ = self.release.release_capacity(self.cap); - } -} impl Chunk { - pub(crate) fn h2(bytes: Bytes, rel_cap: &ReleaseCapacity) -> Chunk { - let cap = bytes.len(); - Chunk { - bytes: bytes, - _flow_control: Some(AutoRelease { - cap: cap, - release: rel_cap.clone(), - }), - } - } - /// Converts this `Chunk` directly into the `Bytes` type without copies. /// /// This is simply an inherent alias for `Bytes::from(chunk)`, which exists, @@ -109,7 +81,6 @@ impl From for Chunk { fn from(bytes: Bytes) -> Chunk { Chunk { bytes: bytes, - _flow_control: None, } } }