proxy: Fix end events not firing when a stream is ended by a DATA frame (#957)

A recent upstream change in `tower-h2` (tower-rs/tower-h2@d9b3140) caused some
HTTP/2 streams that were previously terminated by TRAILERS frames to be 
terminated by empty DATA frames with the end of stream bit set, instead.

This broke some tests in my dev branch for #944, as our test server also uses
`tower-h2`, and some of the metrics tests were no longer seeing the expected
`StreamResponseEnd` events due to this change. This issue may also occur in
other cases, resulting in incorrect metrics.

This PR changes `MeasuredBody::poll_data` to trigger the Stream End event if
it sees a DATA frame that ends the stream.

Fixes #954 

Signed-off-by: Eliza Weisman <eliza@buoyant.io>
This commit is contained in:
Eliza Weisman 2018-05-16 16:24:29 -07:00 committed by GitHub
parent b23ed6e651
commit 4473fd114d
1 changed files with 9 additions and 0 deletions

View File

@ -442,6 +442,15 @@ where
} }
frame frame
}); });
// If the frame ended the stream, send the end of stream event now,
// as we may not be polled again.
if self.is_end_stream() {
if let Some(inner) = self.inner.take() {
inner.end(None);
}
}
Ok(Async::Ready(frame)) Ok(Async::Ready(frame))
} }