fix improper handling of request body backpressure

Closes #348
This commit is contained in:
Sean McArthur
2018-09-19 14:20:08 -07:00
parent 276c3d6594
commit 2698148743
8 changed files with 166 additions and 68 deletions

View File

@@ -93,7 +93,7 @@ impl Form {
pub(crate) fn compute_length(&mut self) -> Option<u64> {
let mut length = 0u64;
for &(ref name, ref field) in self.fields.iter() {
match ::body::len(&field.value) {
match field.value.len() {
Some(value_length) => {
// We are constructing the header just to get its length. To not have to
// construct it again when the request is sent we cache these headers.
@@ -272,7 +272,7 @@ impl Reader {
});
let reader = boundary
.chain(header)
.chain(::body::reader(field.value))
.chain(field.value.into_reader())
.chain(Cursor::new("\r\n"));
// According to https://tools.ietf.org/html/rfc2046#section-5.1.1
// the very last field has a special boundary