diff --git a/gems/aws-sdk-core/CHANGELOG.md b/gems/aws-sdk-core/CHANGELOG.md index 82d5d71ba75..2ab142725be 100644 --- a/gems/aws-sdk-core/CHANGELOG.md +++ b/gems/aws-sdk-core/CHANGELOG.md @@ -1,6 +1,8 @@ Unreleased Changes ------------------ +* Issue - Preserve existing Content-Encoding when applying request trailer checksum. + 3.241.1 (2026-01-06) ------------------ diff --git a/gems/aws-sdk-core/lib/aws-sdk-core/plugins/checksum_algorithm.rb b/gems/aws-sdk-core/lib/aws-sdk-core/plugins/checksum_algorithm.rb index 31e2010b546..c172ef678d0 100644 --- a/gems/aws-sdk-core/lib/aws-sdk-core/plugins/checksum_algorithm.rb +++ b/gems/aws-sdk-core/lib/aws-sdk-core/plugins/checksum_algorithm.rb @@ -381,7 +381,12 @@ def apply_request_trailer_checksum(context, headers, checksum_properties) location_name = checksum_properties[:name] # set required headers - headers['Content-Encoding'] = 'aws-chunked' + headers['Content-Encoding'] = + if headers['Content-Encoding'] + headers['Content-Encoding'] += ', aws-chunked' + else + 'aws-chunked' + end headers['X-Amz-Content-Sha256'] = 'STREAMING-UNSIGNED-PAYLOAD-TRAILER' headers['X-Amz-Trailer'] = location_name diff --git a/gems/aws-sdk-s3/spec/plugins/checksum_algorithm_spec.rb b/gems/aws-sdk-s3/spec/plugins/checksum_algorithm_spec.rb index 3590e860294..d3452c6e462 100644 --- a/gems/aws-sdk-s3/spec/plugins/checksum_algorithm_spec.rb +++ b/gems/aws-sdk-s3/spec/plugins/checksum_algorithm_spec.rb @@ -111,6 +111,18 @@ module Plugins end end + context 'request trailer checksum', skip: defined?(JRUBY_VERSION) do + it 'sets aws-chunked when no existing Content-Encoding header' do + resp = client.put_object(bucket: bucket, key: key, body: body) + expect(resp.context.http_request.headers['Content-Encoding']).to eq('aws-chunked') + end + + it 'appends aws-chunked to existing Content-Encoding header' do + resp = client.put_object(bucket: bucket, key: key, body: body, content_encoding: 'gzip') + expect(resp.context.http_request.headers['Content-Encoding']).to eq('gzip, aws-chunked') + end + end + context 'AwsChunkedTrailerDigestIO' do let(:subject) do ChecksumAlgorithm::AwsChunkedTrailerDigestIO.new(