mirror of
https://github.com/actix/actix-extras.git
synced 2024-11-27 17:22:57 +01:00
Content-Length is 0 for NamedFile HEAD request #914
This commit is contained in:
parent
c8118e8411
commit
bf48798bce
@ -1,8 +1,10 @@
|
|||||||
# Changes
|
# 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
|
## [0.1.1] - 2019-06-01
|
||||||
|
|
||||||
|
@ -926,6 +926,29 @@ mod tests {
|
|||||||
assert_eq!(bytes.freeze(), data);
|
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]
|
#[test]
|
||||||
fn test_static_files_with_spaces() {
|
fn test_static_files_with_spaces() {
|
||||||
let mut srv = test::init_service(
|
let mut srv = test::init_service(
|
||||||
|
@ -422,9 +422,6 @@ impl Responder for NamedFile {
|
|||||||
return Ok(resp.status(StatusCode::NOT_MODIFIED).finish());
|
return Ok(resp.status(StatusCode::NOT_MODIFIED).finish());
|
||||||
}
|
}
|
||||||
|
|
||||||
if *req.method() == Method::HEAD {
|
|
||||||
Ok(resp.finish())
|
|
||||||
} else {
|
|
||||||
let reader = ChunkedReadFile {
|
let reader = ChunkedReadFile {
|
||||||
offset,
|
offset,
|
||||||
size: length,
|
size: length,
|
||||||
@ -438,4 +435,3 @@ impl Responder for NamedFile {
|
|||||||
Ok(resp.body(SizedStream::new(length, reader)))
|
Ok(resp.body(SizedStream::new(length, reader)))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
Loading…
Reference in New Issue
Block a user