diff --git a/actix-files/CHANGES.md b/actix-files/CHANGES.md index 7901a392b..22c98d7c5 100644 --- a/actix-files/CHANGES.md +++ b/actix-files/CHANGES.md @@ -3,6 +3,7 @@ ## [Unreleased] - 2020-xx-xx * Bump minimum supported Rust version to 1.40 +* Support sending Content-Length when Content-Range is specified #1384 ## [0.2.1] - 2019-12-22 diff --git a/actix-files/src/lib.rs b/actix-files/src/lib.rs index 63c499c23..2a5d9a42a 100644 --- a/actix-files/src/lib.rs +++ b/actix-files/src/lib.rs @@ -985,7 +985,7 @@ mod tests { // Valid range header let response = srv - .head("/") + .get("/") .header(header::RANGE, "bytes=10-20") .send() .await @@ -995,7 +995,7 @@ mod tests { // Valid range header, starting from 0 let response = srv - .head("/") + .get("/") .header(header::RANGE, "bytes=0-20") .send() .await @@ -1018,6 +1018,28 @@ mod tests { assert_eq!(bytes, data); } + #[actix_rt::test] + async fn test_head_content_length_headers() { + let srv = test::start(|| { + App::new().service(Files::new("/", ".").index_file("tests/test.binary")) + }); + + let response = srv + .head("/") + .send() + .await + .unwrap(); + + let content_length = response + .headers() + .get(header::CONTENT_LENGTH) + .unwrap() + .to_str() + .unwrap(); + + assert_eq!(content_length, "100"); + } + #[actix_rt::test] async fn test_static_files_with_spaces() { let mut srv = test::init_service(