summaryrefslogtreecommitdiff
path: root/ext/http/lib.rs
diff options
context:
space:
mode:
Diffstat (limited to 'ext/http/lib.rs')
-rw-r--r--ext/http/lib.rs9
1 files changed, 9 insertions, 0 deletions
diff --git a/ext/http/lib.rs b/ext/http/lib.rs
index bffe3c3d5..a8c2810bc 100644
--- a/ext/http/lib.rs
+++ b/ext/http/lib.rs
@@ -39,6 +39,8 @@ use flate2::write::GzEncoder;
use flate2::Compression;
use fly_accept_encoding::Encoding;
use hyper::body::Bytes;
+use hyper::body::HttpBody;
+use hyper::body::SizeHint;
use hyper::header::HeaderName;
use hyper::header::HeaderValue;
use hyper::server::conn::Http;
@@ -309,6 +311,7 @@ pub struct HttpStreamResource {
wr: AsyncRefCell<HttpResponseWriter>,
accept_encoding: Encoding,
cancel_handle: CancelHandle,
+ size: SizeHint,
}
impl HttpStreamResource {
@@ -318,11 +321,13 @@ impl HttpStreamResource {
response_tx: oneshot::Sender<Response<Body>>,
accept_encoding: Encoding,
) -> Self {
+ let size = request.body().size_hint();
Self {
conn: conn.clone(),
rd: HttpRequestReader::Headers(request).into(),
wr: HttpResponseWriter::Headers(response_tx).into(),
accept_encoding,
+ size,
cancel_handle: CancelHandle::new(),
}
}
@@ -388,6 +393,10 @@ impl Resource for HttpStreamResource {
fn close(self: Rc<Self>) {
self.cancel_handle.cancel();
}
+
+ fn size_hint(&self) -> (u64, Option<u64>) {
+ (self.size.lower(), self.size.upper())
+ }
}
/// The read half of an HTTP stream.