mirror of
https://github.com/versity/versitygw.git
synced 2026-09-29 03:05:34 +00:00
fix: strip aws-chunked when the request declares no payload type
`ParseContentEncoding` dropped the `aws-chunked` token only for streaming payload types, so a presigned request kept it: such a request is signed as `UNSIGNED-PAYLOAD` and sends no `x-amz-content-sha256` header, and S3 strips the token there. Keep it only when the request declares a non streaming payload type. S3 applies this to the `Content-Encoding` header before any API sees it, so `CopyObject` and `CreateMultipartUpload` follow the same rule even though neither carries a body to frame. `POSTObject` takes its value from a form field rather than the header and is left alone.
This commit is contained in:
@@ -1557,11 +1557,20 @@ func TestParseContentEncoding(t *testing.T) {
|
||||
{"streaming, token is a prefix of another coding", "STREAMING-UNSIGNED-PAYLOAD-TRAILER", "aws-chunked-custom", "aws-chunked-custom"},
|
||||
{"streaming, no aws-chunked", "STREAMING-UNSIGNED-PAYLOAD-TRAILER", "gzip", "gzip"},
|
||||
{"streaming, no content encoding", "STREAMING-UNSIGNED-PAYLOAD-TRAILER", "", ""},
|
||||
// not streaming: the token is a value the client chose, and S3 keeps it
|
||||
// no payload type: a presigned request is signed as UNSIGNED-PAYLOAD and
|
||||
// may still frame its body, so S3 drops the token
|
||||
{"no payload type, only aws-chunked", "", "aws-chunked", ""},
|
||||
{"no payload type, aws-chunked first", "", "aws-chunked,gzip", "gzip"},
|
||||
{"no payload type, aws-chunked last", "", "gzip,aws-chunked", "gzip"},
|
||||
{"no payload type, uppercase", "", "AWS-CHUNKED", ""},
|
||||
{"no payload type, token is a prefix of another coding", "", "aws-chunked-custom", "aws-chunked-custom"},
|
||||
{"no payload type, no aws-chunked", "", "gzip", "gzip"},
|
||||
// a declared non streaming payload type: the token is a value the client
|
||||
// chose, and S3 keeps it
|
||||
{"hex payload keeps aws-chunked", "9f86d081884c7d659a2feaa0c55ad015a3bf4f1b2b0b822cd15d6c15b0f00a08", "aws-chunked", "aws-chunked"},
|
||||
{"hex payload keeps other codings", "9f86d081884c7d659a2feaa0c55ad015a3bf4f1b2b0b822cd15d6c15b0f00a08", "aws-chunked,gzip", "aws-chunked,gzip"},
|
||||
{"unsigned payload keeps aws-chunked", "UNSIGNED-PAYLOAD", "aws-chunked", "aws-chunked"},
|
||||
{"ecdsa streaming is not chunk decoded, so the value is kept", "STREAMING-AWS4-ECDSA-P256-SHA256-PAYLOAD", "aws-chunked", "aws-chunked"},
|
||||
{"no payload header", "", "gzip", "gzip"},
|
||||
}
|
||||
for _, tt := range tests {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
|
||||
Reference in New Issue
Block a user