This commit is contained in:
parent
f3c3892774
commit
3a053aeaa4
1 changed files with 3 additions and 0 deletions
|
@ -162,6 +162,7 @@ impl<'r> Responder<'r, 'static> for DataResponse {
|
||||||
|duration| Header::new("Cache-Control", format!("public, max-age={duration}")),
|
|duration| Header::new("Cache-Control", format!("public, max-age={duration}")),
|
||||||
);
|
);
|
||||||
|
|
||||||
|
let size = self.data.len();
|
||||||
let data_full = self.data.full();
|
let data_full = self.data.full();
|
||||||
|
|
||||||
if let Ok(raw) = data_full {
|
if let Ok(raw) = data_full {
|
||||||
|
@ -169,6 +170,7 @@ impl<'r> Responder<'r, 'static> for DataResponse {
|
||||||
.header(cache_control_header)
|
.header(cache_control_header)
|
||||||
.header(Header::new("Accept-Ranges", "bytes"))
|
.header(Header::new("Accept-Ranges", "bytes"))
|
||||||
.header(Header::new("Content-Type", self.content_type))
|
.header(Header::new("Content-Type", self.content_type))
|
||||||
|
.header(Header::new("Content-Length", size.to_string()))
|
||||||
.streamed_body(Cursor::new(raw))
|
.streamed_body(Cursor::new(raw))
|
||||||
.finalize())
|
.finalize())
|
||||||
} else {
|
} else {
|
||||||
|
@ -176,6 +178,7 @@ impl<'r> Responder<'r, 'static> for DataResponse {
|
||||||
.header(cache_control_header)
|
.header(cache_control_header)
|
||||||
.header(Header::new("Accept-Ranges", "bytes"))
|
.header(Header::new("Accept-Ranges", "bytes"))
|
||||||
.header(Header::new("Content-Type", self.content_type))
|
.header(Header::new("Content-Type", self.content_type))
|
||||||
|
.header(Header::new("Content-Length", size.to_string()))
|
||||||
.streamed_body(data_full.unwrap_err())
|
.streamed_body(data_full.unwrap_err())
|
||||||
.finalize())
|
.finalize())
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue