S3: Fix Content-Encoding header not preserved (#7894) (#7895)

* S3: Fix Content-Encoding header not preserved (#7894)

The Content-Encoding header was not being returned in S3 GET/HEAD responses
because it wasn't being stored in metadata during PUT operations.

Root cause: The putToFiler function only stored a hardcoded list of standard
HTTP headers (Cache-Control, Expires, Content-Disposition) but was missing
Content-Encoding and Content-Language.

Fix: Added Content-Encoding and Content-Language to the list of standard
headers that are stored in entry.Extended during PUT operations.

This matches the behavior of ParseS3Metadata (used for multipart uploads)
and ensures consistency across all S3 operations.

Fixes #7894

* Update s3api_object_handlers_put.go
This commit is contained in:
Chris Lu
2025-12-27 12:25:33 -08:00
committed by GitHub
parent 6de6061ce9
commit ef20873c31
2 changed files with 209 additions and 2 deletions

View File

@@ -559,8 +559,11 @@ func (s3a *S3ApiServer) putToFiler(r *http.Request, filePath string, dataReader
// Go's HTTP server canonicalizes headers (e.g., x-amz-meta-foo → X-Amz-Meta-Foo)
// We store them as they come in (after canonicalization) to preserve the user's intent
entry.Extended[k] = []byte(v[0])
} else if k == "Cache-Control" || k == "Expires" || k == "Content-Disposition" {
entry.Extended[k] = []byte(v[0])
} else {
switch k {
case "Cache-Control", "Expires", "Content-Disposition", "Content-Encoding", "Content-Language":
entry.Extended[k] = []byte(v[0])
}
}
if k == "Response-Content-Disposition" {
entry.Extended["Content-Disposition"] = []byte(v[0])