mirror of
https://github.com/deuxfleurs-org/garage.git
synced 2026-08-13 07:46:51 +00:00
don't send empty 404 on GetBucketCORS/GetBucketLifecycle (#1378)
Reviewed-on: https://git.deuxfleurs.fr/Deuxfleurs/garage/pulls/1378 Reviewed-by: Alex <lx@deuxfleurs.fr> Co-authored-by: trinity-1686a <trinity@deuxfleurs.fr> Co-committed-by: trinity-1686a <trinity@deuxfleurs.fr>
This commit is contained in:
+1
-3
@@ -28,9 +28,7 @@ pub async fn handle_get_cors(ctx: ReqCtx) -> Result<Response<ResBody>, Error> {
|
||||
.header(http::header::CONTENT_TYPE, "application/xml")
|
||||
.body(string_body(xml))?)
|
||||
} else {
|
||||
Ok(Response::builder()
|
||||
.status(StatusCode::NOT_FOUND)
|
||||
.body(empty_body())?)
|
||||
Err(Error::NoSuchCORSConfiguration)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+14
-1
@@ -42,6 +42,14 @@ pub enum Error {
|
||||
#[error("Upload not found")]
|
||||
NoSuchUpload,
|
||||
|
||||
/// CORS configuration doesn't exist for this bucket
|
||||
#[error("The CORS configuration does not exist")]
|
||||
NoSuchCORSConfiguration,
|
||||
|
||||
/// CORS configuration doesn't exist for this bucket
|
||||
#[error("The lifecycle configuration does not exist")]
|
||||
NoSuchLifecycleConfiguration,
|
||||
|
||||
/// Precondition failed (e.g. x-amz-copy-source-if-match)
|
||||
#[error("At least one of the preconditions you specified did not hold")]
|
||||
PreconditionFailed,
|
||||
@@ -151,6 +159,8 @@ impl Error {
|
||||
Error::InvalidDigest(_) => "InvalidDigest",
|
||||
Error::InvalidUtf8Str(_) | Error::InvalidUtf8String(_) => "InvalidRequest",
|
||||
Error::InvalidEncryptionAlgorithm(_) => "InvalidEncryptionAlgorithmError",
|
||||
Error::NoSuchCORSConfiguration => "NoSuchCORSConfiguration",
|
||||
Error::NoSuchLifecycleConfiguration => "NoSuchLifecycleConfiguration",
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -160,7 +170,10 @@ impl ApiError for Error {
|
||||
fn http_status_code(&self) -> StatusCode {
|
||||
match self {
|
||||
Error::Common(c) => c.http_status_code(),
|
||||
Error::NoSuchKey | Error::NoSuchUpload => StatusCode::NOT_FOUND,
|
||||
Error::NoSuchKey
|
||||
| Error::NoSuchUpload
|
||||
| Error::NoSuchCORSConfiguration
|
||||
| Error::NoSuchLifecycleConfiguration => StatusCode::NOT_FOUND,
|
||||
Error::PreconditionFailed => StatusCode::PRECONDITION_FAILED,
|
||||
Error::InvalidRange(_) => StatusCode::RANGE_NOT_SATISFIABLE,
|
||||
Error::NotImplemented(_) => StatusCode::NOT_IMPLEMENTED,
|
||||
|
||||
@@ -26,9 +26,7 @@ pub async fn handle_get_lifecycle(ctx: ReqCtx) -> Result<Response<ResBody>, Erro
|
||||
.header(http::header::CONTENT_TYPE, "application/xml")
|
||||
.body(string_body(xml))?)
|
||||
} else {
|
||||
Ok(Response::builder()
|
||||
.status(StatusCode::NOT_FOUND)
|
||||
.body(empty_body())?)
|
||||
Err(Error::NoSuchLifecycleConfiguration)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user