Reformulate patch
This commit is contained in:
parent
bd7e3d1bd1
commit
76b489f3d3
1 changed files with 7 additions and 5 deletions
|
@ -15,7 +15,6 @@ use crate::error::*;
|
||||||
fn object_headers(
|
fn object_headers(
|
||||||
version: &ObjectVersion,
|
version: &ObjectVersion,
|
||||||
version_meta: &ObjectVersionMeta,
|
version_meta: &ObjectVersionMeta,
|
||||||
partial_size: Option<u64>
|
|
||||||
) -> http::response::Builder {
|
) -> http::response::Builder {
|
||||||
let date = UNIX_EPOCH + Duration::from_millis(version.timestamp);
|
let date = UNIX_EPOCH + Duration::from_millis(version.timestamp);
|
||||||
let date_str = httpdate::fmt_http_date(date);
|
let date_str = httpdate::fmt_http_date(date);
|
||||||
|
@ -25,7 +24,6 @@ fn object_headers(
|
||||||
"Content-Type",
|
"Content-Type",
|
||||||
version_meta.headers.content_type.to_string(),
|
version_meta.headers.content_type.to_string(),
|
||||||
)
|
)
|
||||||
.header("Content-Length", format!("{}", partial_size.unwrap_or(version_meta.size)))
|
|
||||||
.header("ETag", version_meta.etag.to_string())
|
.header("ETag", version_meta.etag.to_string())
|
||||||
.header("Last-Modified", date_str)
|
.header("Last-Modified", date_str)
|
||||||
.header("Accept-Ranges", format!("bytes"));
|
.header("Accept-Ranges", format!("bytes"));
|
||||||
|
@ -63,7 +61,8 @@ pub async fn handle_head(
|
||||||
};
|
};
|
||||||
|
|
||||||
let body: Body = Body::from(vec![]);
|
let body: Body = Body::from(vec![]);
|
||||||
let response = object_headers(&version, version_meta, None)
|
let response = object_headers(&version, version_meta)
|
||||||
|
.header("Content-Length", format!("{}", version_meta.size))
|
||||||
.status(StatusCode::OK)
|
.status(StatusCode::OK)
|
||||||
.body(body)
|
.body(body)
|
||||||
.unwrap();
|
.unwrap();
|
||||||
|
@ -124,7 +123,9 @@ pub async fn handle_get(
|
||||||
.await;
|
.await;
|
||||||
}
|
}
|
||||||
|
|
||||||
let resp_builder = object_headers(&last_v, last_v_meta, None).status(StatusCode::OK);
|
let resp_builder = object_headers(&last_v, last_v_meta)
|
||||||
|
.header("Content-Length", format!("{}", last_v_meta.size))
|
||||||
|
.status(StatusCode::OK);
|
||||||
|
|
||||||
match &last_v_data {
|
match &last_v_data {
|
||||||
ObjectVersionData::DeleteMarker => unreachable!(),
|
ObjectVersionData::DeleteMarker => unreachable!(),
|
||||||
|
@ -181,7 +182,8 @@ pub async fn handle_get_range(
|
||||||
return Err(Error::BadRequest(format!("Range not included in file")));
|
return Err(Error::BadRequest(format!("Range not included in file")));
|
||||||
}
|
}
|
||||||
|
|
||||||
let resp_builder = object_headers(version, version_meta, Some(end - begin))
|
let resp_builder = object_headers(version, version_meta)
|
||||||
|
.header("Content-Length", format!("{}", end - begin))
|
||||||
.header(
|
.header(
|
||||||
"Content-Range",
|
"Content-Range",
|
||||||
format!("bytes {}-{}/{}", begin, end - 1, version_meta.size),
|
format!("bytes {}-{}/{}", begin, end - 1, version_meta.size),
|
||||||
|
|
Loading…
Reference in a new issue