There is no need to set no_chunking

This commit is contained in:
Omid Rad 2020-05-09 09:10:43 +02:00
parent c0e7caed67
commit fde825f02e
2 changed files with 6 additions and 6 deletions

View File

@ -584,8 +584,7 @@ impl Service for FilesService {
named_file.flags = self.file_flags; named_file.flags = self.file_flags;
let (req, _) = req.into_parts(); let (req, _) = req.into_parts();
match named_file.into_response(&req) { match named_file.into_response(&req) {
Ok(mut item) => { Ok(item) => {
item.head_mut().no_chunking(true);
Either::Left(ok(ServiceResponse::new(req.clone(), item))) Either::Left(ok(ServiceResponse::new(req.clone(), item)))
} }
Err(e) => Either::Left(ok(ServiceResponse::from_err(e, req))), Err(e) => Either::Left(ok(ServiceResponse::from_err(e, req))),

View File

@ -388,11 +388,12 @@ impl NamedFile {
fut: None, fut: None,
counter: 0, counter: 0,
}; };
if offset != 0 {
Ok(resp.status(StatusCode::PARTIAL_CONTENT).streaming(reader)) if offset != 0 || length != self.md.len() {
} else { resp.status(StatusCode::PARTIAL_CONTENT);
Ok(resp.body(SizedStream::new(length, reader)))
} }
Ok(resp.body(SizedStream::new(length, reader)))
} }
} }