fix: match S3's Content-Encoding error details for aws-chunked with UNSIGNED-PAYLOAD

The rejection now reports `Content-Encoding` as the `ArgumentName` and the bare `aws-chunked` token as the `ArgumentValue`, rather than `x-amz-content-sha256` and the payload type, so a request sending `gzip,aws-chunked` gets back just the offending coding, and the message carries S3's trailing period.

Adds integration tests for the three cases: `UnsignedStreamingPayloadTrailer_strips_aws_chunked_content_encoding` for a framed upload where only `aws-chunked` is dropped and the remaining codings keep their order, `PutObject_plain_stores_aws_chunked_content_encoding` for a hex-payload PUT that stores the token as sent, and `PutObject_unsigned_payload_with_aws_chunked_content_encoding` for the full error shape across four header spellings.
This commit is contained in:
niksis02
2026-09-22 02:04:34 +04:00
parent 25f9790c0a
commit 888fd5c1ad
7 changed files with 169 additions and 8 deletions
+5 -5
View File
@@ -1113,15 +1113,15 @@ func ValidateLocationConstraint(constraint *string, region string) error {
return nil
}
// The coding a client announces when it frames a body in aws-chunked, as the
// SDKs do to carry a trailing checksum.
const awsChunkedEncoding = "aws-chunked"
// AwsChunkedEncoding is the coding a client announces when it frames a body in
// aws-chunked, as the SDKs do to carry a trailing checksum.
const AwsChunkedEncoding = "aws-chunked"
// HasAwsChunkedEncoding reports whether a Content-Encoding value carries the
// aws-chunked token.
func HasAwsChunkedEncoding(contentEncoding string) bool {
for _, coding := range strings.Split(contentEncoding, ",") {
if strings.EqualFold(strings.TrimSpace(coding), awsChunkedEncoding) {
if strings.EqualFold(strings.TrimSpace(coding), AwsChunkedEncoding) {
return true
}
}
@@ -1143,7 +1143,7 @@ func ParseContentEncoding(ctx fiber.Ctx) string {
kept := make([]string, 0, len(codings))
for _, coding := range codings {
trimmed := strings.TrimSpace(coding)
if trimmed == "" || strings.EqualFold(trimmed, awsChunkedEncoding) {
if trimmed == "" || strings.EqualFold(trimmed, AwsChunkedEncoding) {
continue
}