fix(http1): fix response with non-chunked transfer-encoding to be close-delimited

Closes #2058
This commit is contained in:
Sean McArthur
2019-12-12 13:02:31 -08:00
parent e12329054a
commit cb71d2cdbd
3 changed files with 55 additions and 3 deletions

View File

@@ -800,7 +800,7 @@ impl Client {
Ok(Some((DecodedLength::CHUNKED, false)))
} else {
trace!("not chunked, read till eof");
Ok(Some((DecodedLength::CHUNKED, false)))
Ok(Some((DecodedLength::CLOSE_DELIMITED, false)))
}
} else if let Some(len) = headers::content_length_parse_all(&inc.headers) {
Ok(Some((DecodedLength::checked_new(len)?, false)))
@@ -1441,7 +1441,7 @@ mod tests {
",
);
// transfer-encoding
// transfer-encoding: chunked
assert_eq!(
parse(
"\
@@ -1454,6 +1454,19 @@ mod tests {
DecodedLength::CHUNKED
);
// transfer-encoding not-chunked is close-delimited
assert_eq!(
parse(
"\
HTTP/1.1 200 OK\r\n\
transfer-encoding: yolo\r\n\
\r\n\
"
)
.decode,
DecodedLength::CLOSE_DELIMITED
);
// transfer-encoding and content-length = chunked
assert_eq!(
parse(