1
0
Fork 0
mirror of https://github.com/actix/actix-web.git synced 2024-11-25 19:11:10 +00:00

Content-Length is 0 for NamedFile HEAD request #914

This commit is contained in:
Nikolay Kim 2019-06-13 15:27:21 +06:00
parent c8118e8411
commit bf48798bce
3 changed files with 38 additions and 17 deletions

View file

@ -1,8 +1,10 @@
# Changes
## [0.1.2] - 2019-06-06
## [0.1.2] - 2019-06-13
* Fix ring dependency from actix-web default features for #741.
* Content-Length is 0 for NamedFile HEAD request #914
* Fix ring dependency from actix-web default features for #741
## [0.1.1] - 2019-06-01

View file

@ -926,6 +926,29 @@ mod tests {
assert_eq!(bytes.freeze(), data);
}
#[test]
fn test_head_content_length_headers() {
let mut srv = test::init_service(
App::new().service(Files::new("test", ".").index_file("tests/test.binary")),
);
// Valid range header
let request = TestRequest::default()
.method(Method::HEAD)
.uri("/t%65st/tests/test.binary")
.to_request();
let response = test::call_service(&mut srv, request);
let contentlength = response
.headers()
.get(header::CONTENT_LENGTH)
.unwrap()
.to_str()
.unwrap();
assert_eq!(contentlength, "100");
}
#[test]
fn test_static_files_with_spaces() {
let mut srv = test::init_service(

View file

@ -422,9 +422,6 @@ impl Responder for NamedFile {
return Ok(resp.status(StatusCode::NOT_MODIFIED).finish());
}
if *req.method() == Method::HEAD {
Ok(resp.finish())
} else {
let reader = ChunkedReadFile {
offset,
size: length,
@ -437,5 +434,4 @@ impl Responder for NamedFile {
};
Ok(resp.body(SizedStream::new(length, reader)))
}
}
}