feat(http2): Add content_length() value to incoming h2 Body

- Add `Body::Kind::H2` to contain the content length of the body.
- Update `Body::content_length` to return the content length if `Body::Kind` is `H2`, instead of returning `None`.

Reference: #1556, #1557

Closes #1546
This commit is contained in:
Josh Leeb-du Toit
2018-06-19 04:50:12 +10:00
committed by Sean McArthur
parent 29a8074689
commit 9a28268b98
4 changed files with 58 additions and 49 deletions

View File

@@ -372,9 +372,7 @@ mod response_body_lengths {
.get(uri)
.and_then(|res| {
assert_eq!(res.headers().get("content-length").unwrap(), "13");
// TODO: enable this after #1546
let _ = res.body().content_length();
// assert_eq!(res.body().content_length(), Some(13));
assert_eq!(res.body().content_length(), Some(13));
Ok(())
})
.map(|_| ())
@@ -403,9 +401,7 @@ mod response_body_lengths {
.get(uri)
.and_then(|res| {
assert_eq!(res.headers().get("content-length").unwrap(), "10");
// TODO: enable or remove this after #1546
let _ = res.body().content_length();
// assert_eq!(res.body().content_length(), Some(10));
assert_eq!(res.body().content_length(), Some(10));
Ok(())
})
.map(|_| ())