Skip to content

Commit

Permalink
multipart: Force a CRLF at the end of request
Browse files Browse the repository at this point in the history
  • Loading branch information
kennytm authored and seanmonstar committed Jul 31, 2018
1 parent a4f5c2d commit 7fd6bb3
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
8 changes: 4 additions & 4 deletions src/multipart_.rs
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ impl Form {
}
// If there is a at least one field there is a special boundary for the very last field.
if self.fields.len() != 0 {
length += 2 + self.boundary.len() as u64 + 2
length += 2 + self.boundary.len() as u64 + 4
}
Some(length)
}
Expand Down Expand Up @@ -272,7 +272,7 @@ impl Reader {
Some(Box::new(reader))
} else {
Some(Box::new(reader.chain(Cursor::new(
format!("--{}--", self.form.boundary),
format!("--{}--\r\n", self.form.boundary),
))))
}
} else {
Expand Down Expand Up @@ -378,7 +378,7 @@ mod tests {
\r\n\
--boundary\r\n\
Content-Disposition: form-data; name=\"key3\"; filename=\"filename\"\r\n\r\n\
value3\r\n--boundary--";
value3\r\n--boundary--\r\n";
form.reader().read_to_end(&mut output).unwrap();
// These prints are for debug purposes in case the test fails
println!(
Expand Down Expand Up @@ -414,7 +414,7 @@ mod tests {
value2\r\n\
--boundary\r\n\
Content-Disposition: form-data; name=\"key3\"; filename=\"filename\"\r\n\r\n\
value3\r\n--boundary--";
value3\r\n--boundary--\r\n";
form.reader().read_to_end(&mut output).unwrap();
// These prints are for debug purposes in case the test fails
println!(
Expand Down
4 changes: 2 additions & 2 deletions tests/multipart.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ fn test_multipart() {
--{0}\r\n\
Content-Disposition: form-data; name=\"foo\"\r\n\r\n\
bar\r\n\
--{0}--\
--{0}--\r\n\
", form.boundary());

let server = server! {
Expand All @@ -25,7 +25,7 @@ fn test_multipart() {
User-Agent: $USERAGENT\r\n\
Accept: */*\r\n\
Content-Type: multipart/form-data; boundary={}\r\n\
Content-Length: 123\r\n\
Content-Length: 125\r\n\
Accept-Encoding: gzip\r\n\
\r\n\
{}\
Expand Down

0 comments on commit 7fd6bb3

Please sign in to comment.