S3 compatibility: fix bucket listing and HEAD and PUT on bucket

This commit is contained in:
Alex Auvolat
2020-04-26 16:22:33 +00:00
parent 0e49e0c8b5
commit ea7e4748ed
2 changed files with 46 additions and 31 deletions
+12 -2
View File
@@ -125,8 +125,18 @@ async fn handler_inner(
}
} else {
match req.method() {
&Method::PUT | &Method::DELETE => Err(Error::Forbidden(
"Cannot create or delete buckets using S3 api, please talk to Garage directly"
&Method::PUT | &Method::HEAD => {
// If PUT: corresponds to a bucket creation call
// If we're here, the bucket already exists, so just answer ok
let empty_body: BodyType = Box::new(BytesBody::from(vec![]));
let response = Response::builder()
.header("Location", format!("/{}", bucket))
.body(empty_body)
.unwrap();
Ok(response)
},
&Method::DELETE => Err(Error::Forbidden(
"Cannot delete buckets using S3 api, please talk to Garage directly"
.into(),
)),
&Method::GET => {