Skip to content

Commit 327f154

Browse files
committed
fix: content-md5 header should be removed as it's altered by the proxy
1 parent c289a8d commit 327f154

3 files changed

Lines changed: 9 additions & 1 deletion

File tree

src/http/handlers/forward.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,14 @@ use std::time::Duration;
1212

1313
const UPLOAD_TIMEOUT: Duration = Duration::from_secs(60 * 60);
1414

15-
static FORWARD_REQUEST_HEADERS_TO_REMOVE: [header::HeaderName; 4] = [
15+
static FORWARD_REQUEST_HEADERS_TO_REMOVE: [header::HeaderName; 5] = [
1616
// Connection settings (keepalived) must not be resend
1717
header::CONNECTION,
1818
// Encryption changes the length of the content
1919
header::CONTENT_LENGTH,
20+
// The Content-MD5 sent by the client is the checksum of the cleartext
21+
// data, it does not match the encrypted body forwarded to the storage
22+
header::HeaderName::from_static("content-md5"),
2023
// Openstack checks the ETAG header as a md5 checksum of the data
2124
// the encryption change the data and thus the etag
2225
header::ETAG,

tests/helpers/curl.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,10 @@ pub fn curl_put(file_path: &str, url: &str) -> Output {
2626
.arg(url)
2727
.arg("--data-binary")
2828
.arg(format!("@{}", file_path))
29+
// checksum of the cleartext data, it must be removed by the proxy
30+
// as the encrypted body no longer matches it
31+
.arg("-H")
32+
.arg("Content-MD5: Q2hlY2tJbnRlZ3JpdHk=")
2933
.arg("--dump-header")
3034
.arg(RETURNED_HEADER)
3135
.output()

tests/upload_and_download.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ fn upload_and_download() {
3636
);
3737
assert!(node_received_header("x-amz-date").is_some());
3838
assert!(node_received_header("authorization").is_some());
39+
assert!(node_received_header("content-md5").is_none());
3940

4041
let uploaded_bytes = std::fs::read(uploaded_path).expect("uploaded should exist !");
4142
assert_eq!(&uploaded_bytes[0..PREFIX_SIZE], PREFIX);

0 commit comments

Comments
 (0)