diff --git a/actix-files/src/lib.rs b/actix-files/src/lib.rs index e8df818cd..6d2da6c73 100644 --- a/actix-files/src/lib.rs +++ b/actix-files/src/lib.rs @@ -584,8 +584,7 @@ impl Service for FilesService { named_file.flags = self.file_flags; let (req, _) = req.into_parts(); match named_file.into_response(&req) { - Ok(mut item) => { - item.head_mut().no_chunking(true); + Ok(item) => { Either::Left(ok(ServiceResponse::new(req.clone(), item))) } Err(e) => Either::Left(ok(ServiceResponse::from_err(e, req))), diff --git a/actix-files/src/named.rs b/actix-files/src/named.rs index 191910602..e05316904 100644 --- a/actix-files/src/named.rs +++ b/actix-files/src/named.rs @@ -388,11 +388,12 @@ impl NamedFile { fut: None, counter: 0, }; - if offset != 0 { - Ok(resp.status(StatusCode::PARTIAL_CONTENT).streaming(reader)) - } else { - Ok(resp.body(SizedStream::new(length, reader))) + + if offset != 0 || length != self.md.len() { + resp.status(StatusCode::PARTIAL_CONTENT); } + + Ok(resp.body(SizedStream::new(length, reader))) } }