🚑️ response sizes
All checks were successful
ci/woodpecker/push/test Pipeline was successful

This commit is contained in:
JMARyA 2025-03-04 19:31:04 +01:00
parent f3c3892774
commit 3a053aeaa4
Signed by: jmarya
GPG key ID: 901B2ADDF27C2263

View file

@ -162,6 +162,7 @@ impl<'r> Responder<'r, 'static> for DataResponse {
|duration| Header::new("Cache-Control", format!("public, max-age={duration}")),
);
let size = self.data.len();
let data_full = self.data.full();
if let Ok(raw) = data_full {
@ -169,6 +170,7 @@ impl<'r> Responder<'r, 'static> for DataResponse {
.header(cache_control_header)
.header(Header::new("Accept-Ranges", "bytes"))
.header(Header::new("Content-Type", self.content_type))
.header(Header::new("Content-Length", size.to_string()))
.streamed_body(Cursor::new(raw))
.finalize())
} else {
@ -176,6 +178,7 @@ impl<'r> Responder<'r, 'static> for DataResponse {
.header(cache_control_header)
.header(Header::new("Accept-Ranges", "bytes"))
.header(Header::new("Content-Type", self.content_type))
.header(Header::new("Content-Length", size.to_string()))
.streamed_body(data_full.unwrap_err())
.finalize())
}