[split_getobject] GetObject: split out handle_get_full
This commit is contained in:
parent
61758ce0f9
commit
d640102b76
1 changed files with 19 additions and 15 deletions
|
@ -253,16 +253,12 @@ pub async fn handle_get(
|
||||||
}
|
}
|
||||||
|
|
||||||
match (part_number, parse_range_header(req, last_v_meta.size)?) {
|
match (part_number, parse_range_header(req, last_v_meta.size)?) {
|
||||||
(Some(_), Some(_)) => {
|
(Some(_), Some(_)) => Err(Error::bad_request(
|
||||||
return Err(Error::bad_request(
|
|
||||||
"Cannot specify both partNumber and Range header",
|
"Cannot specify both partNumber and Range header",
|
||||||
));
|
)),
|
||||||
}
|
(Some(pn), None) => handle_get_part(garage, last_v, last_v_data, last_v_meta, pn).await,
|
||||||
(Some(pn), None) => {
|
|
||||||
return handle_get_part(garage, last_v, last_v_data, last_v_meta, pn).await;
|
|
||||||
}
|
|
||||||
(None, Some(range)) => {
|
(None, Some(range)) => {
|
||||||
return handle_get_range(
|
handle_get_range(
|
||||||
garage,
|
garage,
|
||||||
last_v,
|
last_v,
|
||||||
last_v_data,
|
last_v_data,
|
||||||
|
@ -270,17 +266,25 @@ pub async fn handle_get(
|
||||||
range.start,
|
range.start,
|
||||||
range.start + range.length,
|
range.start + range.length,
|
||||||
)
|
)
|
||||||
.await;
|
.await
|
||||||
|
}
|
||||||
|
(None, None) => handle_get_full(garage, last_v, last_v_data, last_v_meta, overrides).await,
|
||||||
}
|
}
|
||||||
(None, None) => (),
|
|
||||||
}
|
}
|
||||||
|
|
||||||
let mut resp_builder = object_headers(last_v, last_v_meta)
|
async fn handle_get_full(
|
||||||
.header(CONTENT_LENGTH, format!("{}", last_v_meta.size))
|
garage: Arc<Garage>,
|
||||||
|
version: &ObjectVersion,
|
||||||
|
version_data: &ObjectVersionData,
|
||||||
|
version_meta: &ObjectVersionMeta,
|
||||||
|
overrides: GetObjectOverrides,
|
||||||
|
) -> Result<Response<ResBody>, Error> {
|
||||||
|
let mut resp_builder = object_headers(version, version_meta)
|
||||||
|
.header(CONTENT_LENGTH, format!("{}", version_meta.size))
|
||||||
.status(StatusCode::OK);
|
.status(StatusCode::OK);
|
||||||
getobject_override_headers(overrides, &mut resp_builder)?;
|
getobject_override_headers(overrides, &mut resp_builder)?;
|
||||||
|
|
||||||
match &last_v_data {
|
match &version_data {
|
||||||
ObjectVersionData::DeleteMarker => unreachable!(),
|
ObjectVersionData::DeleteMarker => unreachable!(),
|
||||||
ObjectVersionData::Inline(_, bytes) => {
|
ObjectVersionData::Inline(_, bytes) => {
|
||||||
Ok(resp_builder.body(bytes_body(bytes.to_vec().into()))?)
|
Ok(resp_builder.body(bytes_body(bytes.to_vec().into()))?)
|
||||||
|
@ -290,7 +294,7 @@ pub async fn handle_get(
|
||||||
|
|
||||||
let order_stream = OrderTag::stream();
|
let order_stream = OrderTag::stream();
|
||||||
let first_block_hash = *first_block_hash;
|
let first_block_hash = *first_block_hash;
|
||||||
let version_uuid = last_v.uuid;
|
let version_uuid = version.uuid;
|
||||||
|
|
||||||
tokio::spawn(async move {
|
tokio::spawn(async move {
|
||||||
match async {
|
match async {
|
||||||
|
|
Loading…
Reference in a new issue