aboutsummaryrefslogtreecommitdiff
path: root/src/api/s3
diff options
context:
space:
mode:
authorAlex Auvolat <alex@adnab.me>2023-10-26 11:27:56 +0200
committerAlex Auvolat <alex@adnab.me>2023-10-26 11:27:56 +0200
commitb1ee3e54ba7f34a32d4098fdbaa481da3363a81c (patch)
tree0fc09b937c16567894e6492a5f33cfe5b11f7ee8 /src/api/s3
parentf4d3905d157869d98f9855cba77b4ba452012703 (diff)
parent4b3dee2ca3be35d2df73626ad36a8cddedc41e6f (diff)
downloadgarage-b1ee3e54ba7f34a32d4098fdbaa481da3363a81c.tar.gz
garage-b1ee3e54ba7f34a32d4098fdbaa481da3363a81c.zip
Merge branch 'main-0.8.x' into sync-08-09sync-08-09
Diffstat (limited to 'src/api/s3')
-rw-r--r--src/api/s3/post_object.rs13
1 files changed, 10 insertions, 3 deletions
diff --git a/src/api/s3/post_object.rs b/src/api/s3/post_object.rs
index 542b7a81..f9eccb7f 100644
--- a/src/api/s3/post_object.rs
+++ b/src/api/s3/post_object.rs
@@ -15,6 +15,7 @@ use serde::Deserialize;
use garage_model::garage::Garage;
+use crate::s3::cors::*;
use crate::s3::error::*;
use crate::s3::put::{get_headers, save_stream};
use crate::s3::xml as s3_xml;
@@ -242,7 +243,7 @@ pub async fn handle_post_object(
let etag = format!("\"{}\"", md5);
- let resp = if let Some(mut target) = params
+ let mut resp = if let Some(mut target) = params
.get("success_action_redirect")
.and_then(|h| h.to_str().ok())
.and_then(|u| url::Url::parse(u).ok())
@@ -262,8 +263,7 @@ pub async fn handle_post_object(
} else {
let path = head
.uri
- .into_parts()
- .path_and_query
+ .path_and_query()
.map(|paq| paq.path().to_string())
.unwrap_or_else(|| "/".to_string());
let authority = head
@@ -308,6 +308,13 @@ pub async fn handle_post_object(
}
};
+ let matching_cors_rule =
+ find_matching_cors_rule(&bucket, &Request::from_parts(head, Body::empty()))?;
+ if let Some(rule) = matching_cors_rule {
+ add_cors_headers(&mut resp, rule)
+ .ok_or_internal_error("Invalid bucket CORS configuration")?;
+ }
+
Ok(resp)
}