aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAlex <lx@deuxfleurs.fr>2025-01-27 19:32:19 +0000
committerAlex <lx@deuxfleurs.fr>2025-01-27 19:32:19 +0000
commita1d081ee840b1727ba1b3f430638a1296738283e (patch)
tree1c4822ec7dec299af99afa22a0614408bc74aabb /src
parentbeedc9fd11d24ccce837cc229ea6c30c980f9baa (diff)
parente8fa89e8348522c368eb17e89ab3209e6a734088 (diff)
downloadgarage-a1d081ee840b1727ba1b3f430638a1296738283e.tar.gz
garage-a1d081ee840b1727ba1b3f430638a1296738283e.zip
Merge pull request 's3 api: make x-amz-meta-* headers lowercase (fix #844)' (#938) from fix-844 into main
Reviewed-on: https://git.deuxfleurs.fr/Deuxfleurs/garage/pulls/938
Diffstat (limited to 'src')
-rw-r--r--src/api/s3/get.rs13
-rw-r--r--src/api/s3/put.rs2
2 files changed, 6 insertions, 9 deletions
diff --git a/src/api/s3/get.rs b/src/api/s3/get.rs
index f5d3cf11..f61aae11 100644
--- a/src/api/s3/get.rs
+++ b/src/api/s3/get.rs
@@ -68,14 +68,11 @@ fn object_headers(
// See: https://docs.aws.amazon.com/AmazonS3/latest/userguide/UsingMetadata.html
let mut headers_by_name = BTreeMap::new();
for (name, value) in meta_inner.headers.iter() {
- match headers_by_name.get_mut(name) {
- None => {
- headers_by_name.insert(name, vec![value.as_str()]);
- }
- Some(headers) => {
- headers.push(value.as_str());
- }
- }
+ let name_lower = name.to_ascii_lowercase();
+ headers_by_name
+ .entry(name_lower)
+ .or_insert(vec![])
+ .push(value.as_str());
}
for (name, values) in headers_by_name {
diff --git a/src/api/s3/put.rs b/src/api/s3/put.rs
index 1e3b1b44..bfb0dc9b 100644
--- a/src/api/s3/put.rs
+++ b/src/api/s3/put.rs
@@ -622,7 +622,7 @@ pub(crate) fn get_headers(headers: &HeaderMap<HeaderValue>) -> Result<HeaderList
for (name, value) in headers.iter() {
if name.as_str().starts_with("x-amz-meta-") {
ret.push((
- name.to_string(),
+ name.as_str().to_ascii_lowercase(),
std::str::from_utf8(value.as_bytes())?.to_string(),
));
}