multipart: Force a CRLF at the end of request
This commit is contained in:
@@ -108,7 +108,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)
|
||||
}
|
||||
@@ -271,7 +271,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 {
|
||||
@@ -377,7 +377,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!(
|
||||
@@ -413,7 +413,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!(
|
||||
|
||||
@@ -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! {
|
||||
@@ -24,7 +24,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\
|
||||
host: $HOST\r\n\
|
||||
\r\n\
|
||||
|
||||
Reference in New Issue
Block a user