aboutsummaryrefslogtreecommitdiff
path: root/src/model
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/model
parente3333f2ac5d142b6faddc6d54bcf35a0465be4bb (diff)
downloadgarage-3fcb54e3cf62cdc9ed84751e1f0522ff553ea63c.tar.gz
garage-3fcb54e3cf62cdc9ed84751e1f0522ff553ea63c.zip
[sse-c] Remove special case for Content-Type headersse-c
Diffstat (limited to 'src/model')
-rw-r--r--src/model/Cargo.toml1
-rw-r--r--src/model/s3/object_table.rs20
2 files changed, 18 insertions, 3 deletions
diff --git a/src/model/Cargo.toml b/src/model/Cargo.toml
index 33898e20..776671d0 100644
--- a/src/model/Cargo.toml
+++ b/src/model/Cargo.toml
@@ -27,6 +27,7 @@ blake2.workspace = true
chrono.workspace = true
err-derive.workspace = true
hex.workspace = true
+http.workspace = true
base64.workspace = true
tracing.workspace = true
rand.workspace = true
diff --git a/src/model/s3/object_table.rs b/src/model/s3/object_table.rs
index 7fa4b9e0..f2d21493 100644
--- a/src/model/s3/object_table.rs
+++ b/src/model/s3/object_table.rs
@@ -216,8 +216,6 @@ mod v010 {
use super::v09;
- pub use v09::ObjectVersionHeaders;
-
/// An object
#[derive(PartialEq, Eq, Clone, Debug, Serialize, Deserialize)]
pub struct Object {
@@ -303,6 +301,10 @@ mod v010 {
},
}
+ /// Vector of headers, as tuples of the format (header name, header value)
+ #[derive(PartialEq, Eq, PartialOrd, Ord, Clone, Debug, Serialize, Deserialize)]
+ pub struct ObjectVersionHeaders(pub Vec<(String, String)>);
+
impl garage_util::migrate::Migrate for Object {
const VERSION_MARKER: &'static [u8] = b"G010s3ob";
@@ -357,7 +359,19 @@ mod v010 {
}
fn migrate_headers(old: v09::ObjectVersionHeaders) -> ObjectVersionEncryption {
- ObjectVersionEncryption::Plaintext { headers: old }
+ use http::header::CONTENT_TYPE;
+
+ let mut new_headers = Vec::with_capacity(old.other.len() + 1);
+ if old.content_type != "blob" {
+ new_headers.push((CONTENT_TYPE.as_str().to_string(), old.content_type));
+ }
+ for (name, value) in old.other.into_iter() {
+ new_headers.push((name, value));
+ }
+
+ ObjectVersionEncryption::Plaintext {
+ headers: ObjectVersionHeaders(new_headers),
+ }
}
// Since ObjectVersionHeaders can now be serialized independently, for the