proxy: Record EOS when bodies are dropped (#1003)

It appears that hyper does not necessarily poll bodies to completion,
and instead simply drops a body as soon as `content-length` is reached
(hyperium/hyper#1521).

This change implements Drop for MeasuredBody such that the stream-end
event is triggered if it had not been triggered previously. This ensures
that response latencies and counts are recorded for HTTP/1 streams.

Fixes #994
This commit is contained in:
Oliver Gould 2018-05-24 10:40:29 -07:00 committed by GitHub
parent 4fdbd1631a
commit 0e6c4c1450
1 changed files with 8 additions and 0 deletions

View File

@ -507,6 +507,14 @@ where
}
impl<B, I: BodySensor> Drop for MeasuredBody<B, I> {
fn drop(&mut self) {
if let Some(inner) = self.inner.take() {
inner.end(None);
}
}
}
// ===== impl BodySensor =====
impl BodySensor for ResponseBodyInner {