diff --git a/src/async_impl/multipart.rs b/src/async_impl/multipart.rs index ac4b8b981..df4dc1272 100644 --- a/src/async_impl/multipart.rs +++ b/src/async_impl/multipart.rs @@ -270,8 +270,9 @@ impl Part { let len = file.metadata().await.map(|m| m.len()).ok(); let field = match len { Some(len) => Part::stream_with_length(file, len), - None => Part::stream(file) - }.mime(mime); + None => Part::stream(file), + } + .mime(mime); Ok(if let Some(file_name) = file_name { field.file_name(file_name) diff --git a/tests/multipart.rs b/tests/multipart.rs index bac6da314..78e170cbc 100644 --- a/tests/multipart.rs +++ b/tests/multipart.rs @@ -208,8 +208,11 @@ async fn async_impl_file_part() { async move { assert_eq!(req.method(), "POST"); assert_eq!(req.headers()["content-type"], ct); - assert_eq!(req.headers()["transfer-encoding"], "chunked"); - + // files know their exact size + assert_eq!( + req.headers()["content-length"], + expected_body.len().to_string() + ); let full = req.collect().await.unwrap().to_bytes(); assert_eq!(full, expected_body.as_bytes());