mirror of
https://github.com/deuxfleurs-org/garage.git
synced 2026-08-09 22:19:23 +00:00
Implement HTTP ranges in get
This commit is contained in:
+18
-21
@@ -73,8 +73,7 @@ async fn handler_inner(
|
||||
req: Request<Body>,
|
||||
) -> Result<Response<BodyType>, Error> {
|
||||
let path = req.uri().path().to_string();
|
||||
let path = percent_encoding::percent_decode_str(&path)
|
||||
.decode_utf8()?;
|
||||
let path = percent_encoding::percent_decode_str(&path).decode_utf8()?;
|
||||
|
||||
let (bucket, key) = parse_bucket_key(&path)?;
|
||||
if bucket.len() == 0 {
|
||||
@@ -110,7 +109,7 @@ async fn handler_inner(
|
||||
}
|
||||
&Method::GET => {
|
||||
// GetObject query
|
||||
Ok(handle_get(garage, &bucket, &key).await?)
|
||||
Ok(handle_get(garage, &req, &bucket, &key).await?)
|
||||
}
|
||||
&Method::PUT => {
|
||||
if params.contains_key(&"partnumber".to_string())
|
||||
@@ -123,8 +122,8 @@ async fn handler_inner(
|
||||
} else if req.headers().contains_key("x-amz-copy-source") {
|
||||
// CopyObject query
|
||||
let copy_source = req.headers().get("x-amz-copy-source").unwrap().to_str()?;
|
||||
let copy_source = percent_encoding::percent_decode_str(©_source)
|
||||
.decode_utf8()?;
|
||||
let copy_source =
|
||||
percent_encoding::percent_decode_str(©_source).decode_utf8()?;
|
||||
let (source_bucket, source_key) = parse_bucket_key(©_source)?;
|
||||
if !api_key.allow_read(&source_bucket) {
|
||||
return Err(Error::Forbidden(format!(
|
||||
@@ -228,22 +227,20 @@ async fn handler_inner(
|
||||
)
|
||||
.await?)
|
||||
}
|
||||
&Method::POST => {
|
||||
if params.contains_key(&"delete".to_string()) {
|
||||
// DeleteObjects
|
||||
Ok(handle_delete_objects(garage, bucket, req).await?)
|
||||
} else {
|
||||
println!(
|
||||
"Body: {}",
|
||||
std::str::from_utf8(&hyper::body::to_bytes(req.into_body()).await?)
|
||||
.unwrap_or("<invalid utf8>")
|
||||
);
|
||||
Err(Error::BadRequest(format!("Unsupported call")))
|
||||
}
|
||||
}
|
||||
_ => {
|
||||
Err(Error::BadRequest(format!("Invalid method")))
|
||||
}
|
||||
&Method::POST => {
|
||||
if params.contains_key(&"delete".to_string()) {
|
||||
// DeleteObjects
|
||||
Ok(handle_delete_objects(garage, bucket, req).await?)
|
||||
} else {
|
||||
println!(
|
||||
"Body: {}",
|
||||
std::str::from_utf8(&hyper::body::to_bytes(req.into_body()).await?)
|
||||
.unwrap_or("<invalid utf8>")
|
||||
);
|
||||
Err(Error::BadRequest(format!("Unsupported call")))
|
||||
}
|
||||
}
|
||||
_ => Err(Error::BadRequest(format!("Invalid method"))),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user