aboutsummaryrefslogtreecommitdiff
path: root/src/api/s3/get.rs
diff options
context:
space:
mode:
authorAlex Auvolat <alex@adnab.me>2024-03-06 19:23:36 +0100
committerAlex Auvolat <alex@adnab.me>2024-03-07 15:43:48 +0100
commit3fcb54e3cf62cdc9ed84751e1f0522ff553ea63c (patch)
tree7c0eb4ebf106c3e624426bd6569b1c1bb4d20e01 /src/api/s3/get.rs
parente3333f2ac5d142b6faddc6d54bcf35a0465be4bb (diff)
downloadgarage-3fcb54e3cf62cdc9ed84751e1f0522ff553ea63c.tar.gz
garage-3fcb54e3cf62cdc9ed84751e1f0522ff553ea63c.zip
[sse-c] Remove special case for Content-Type headersse-c
Diffstat (limited to 'src/api/s3/get.rs')
-rw-r--r--src/api/s3/get.rs21
1 files changed, 18 insertions, 3 deletions
diff --git a/src/api/s3/get.rs b/src/api/s3/get.rs
index 1bca4671..ec300ab7 100644
--- a/src/api/s3/get.rs
+++ b/src/api/s3/get.rs
@@ -1,4 +1,5 @@
//! Function related to GET and HEAD requests
+use std::collections::BTreeMap;
use std::convert::TryInto;
use std::sync::Arc;
use std::time::{Duration, UNIX_EPOCH};
@@ -53,7 +54,6 @@ fn object_headers(
let date_str = httpdate::fmt_http_date(date);
let mut resp = Response::builder()
- .header(CONTENT_TYPE, headers.content_type.to_string())
.header(LAST_MODIFIED, date_str)
.header(ACCEPT_RANGES, "bytes".to_string());
@@ -61,8 +61,23 @@ fn object_headers(
resp = resp.header(ETAG, format!("\"{}\"", version_meta.etag));
}
- for (k, v) in headers.other.iter() {
- resp = resp.header(k, v.to_string());
+ // When metadata is retrieved through the REST API, Amazon S3 combines headers that
+ // have the same name (ignoring case) into a comma-delimited list.
+ // See: https://docs.aws.amazon.com/AmazonS3/latest/userguide/UsingMetadata.html
+ let mut headers_by_name = BTreeMap::new();
+ for (name, value) in headers.0.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());
+ }
+ }
+ }
+
+ for (name, values) in headers_by_name {
+ resp = resp.header(name, values.join(","));
}
encryption.add_response_headers(&mut resp);