diff --git a/awscli/botocore/httpchecksum.py b/awscli/botocore/httpchecksum.py index e90bab61962a..122f84de3a3e 100644 --- a/awscli/botocore/httpchecksum.py +++ b/awscli/botocore/httpchecksum.py @@ -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) diff --git a/tests/functional/botocore/test_s3.py b/tests/functional/botocore/test_s3.py index 937eb1ae8e9a..4b159a6252ed 100644 --- a/tests/functional/botocore/test_s3.py +++ b/tests/functional/botocore/test_s3.py @@ -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',