Skip to content

Commit

Permalink
Ignore Content-Length header when setting 'chunked' for Transfer-Enco…
Browse files Browse the repository at this point in the history
…ding
  • Loading branch information
jonathan343 committed Jan 30, 2025
1 parent 2813918 commit d2eea98
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
8 changes: 7 additions & 1 deletion awscli/botocore/httpchecksum.py
Original file line number Diff line number Diff line change
Expand Up @@ -388,7 +388,13 @@ def _apply_request_trailer_checksum(request):
# Send the decoded content length if we can determine it. Some
# services such as S3 may require the decoded content length
headers["X-Amz-Decoded-Content-Length"] = str(content_length)


if "Content-Length" in headers:
del headers["Content-Length"]
logger.debug(
"Removing the Content-Length header since 'chunked' is specified for Transfer-Encoding."
)

if isinstance(body, (bytes, bytearray)):
body = io.BytesIO(body)

Expand Down
7 changes: 6 additions & 1 deletion tests/functional/botocore/test_s3.py
Original file line number Diff line number Diff line change
Expand Up @@ -1558,7 +1558,12 @@ class TestCanSendIntegerHeaders(BaseSessionTest):

def test_int_values_with_sigv4(self):
s3 = self.session.create_client(
's3', config=Config(signature_version='s3v4'))
"s3",
config=Config(
signature_version="s3v4",
request_checksum_calculation="when_required",
),
)
with ClientHTTPStubber(s3) as http_stubber:
http_stubber.add_response()
s3.upload_part(Bucket='foo', Key='bar', Body=b'foo',
Expand Down

0 comments on commit d2eea98

Please sign in to comment.