fix(http1): reduce closed connections when body is dropped

If a user makes use of `Body::is_end_stream` to optimize so as to not
need to do make a final poll just to receive `None`, previously the
connection would not have progressed its reading state to a finished
body, and so the connection would be closed.

Now, upon reading any chunk, the connection state will check if it
can know that the body would be finished, and progresses to a body
finished state sooner.

The integration tests were amplified by adding a naive hyper proxy
as a secondary test, which happens to make use of that optimization,
and thus caught the issue.
This commit is contained in:
Sean McArthur
2018-07-21 16:17:08 -07:00
parent 05c1179e82
commit 6530a00a8e
4 changed files with 163 additions and 37 deletions

View File

@@ -62,6 +62,50 @@ t! {
;
}
t! {
get_body_2_keeps_alive,
client:
request:
uri: "/",
;
response:
status: 200,
headers: {
"content-length" => 11,
},
body: "hello world",
;
request:
uri: "/",
;
response:
status: 200,
headers: {
"content-length" => 11,
},
body: "hello world",
;
server:
request:
uri: "/",
;
response:
headers: {
"content-length" => 11,
},
body: "hello world",
;
request:
uri: "/",
;
response:
headers: {
"content-length" => 11,
},
body: "hello world",
;
}
t! {
get_strip_connection_header,
client: