S3: Return checksum header only if set (#5765)
This commit is contained in:
parent
c498c14ba3
commit
77cf4e3143
@ -1556,7 +1556,8 @@ class S3Response(BaseResponse):
|
|||||||
new_key.website_redirect_location = request.headers.get(
|
new_key.website_redirect_location = request.headers.get(
|
||||||
"x-amz-website-redirect-location"
|
"x-amz-website-redirect-location"
|
||||||
)
|
)
|
||||||
new_key.checksum_algorithm = checksum_algorithm
|
if checksum_algorithm:
|
||||||
|
new_key.checksum_algorithm = checksum_algorithm
|
||||||
self.backend.set_key_tags(new_key, tagging)
|
self.backend.set_key_tags(new_key, tagging)
|
||||||
|
|
||||||
response_headers.update(new_key.response_dict)
|
response_headers.update(new_key.response_dict)
|
||||||
|
@ -1400,6 +1400,11 @@ def test_list_objects_v2_truncate_combined_keys_and_folders():
|
|||||||
def test_list_objects_v2_checksum_algo():
|
def test_list_objects_v2_checksum_algo():
|
||||||
s3 = boto3.client("s3", region_name=DEFAULT_REGION_NAME)
|
s3 = boto3.client("s3", region_name=DEFAULT_REGION_NAME)
|
||||||
s3.create_bucket(Bucket="mybucket")
|
s3.create_bucket(Bucket="mybucket")
|
||||||
|
resp = s3.put_object(Bucket="mybucket", Key="0", Body="a")
|
||||||
|
resp.should_not.have.key("ChecksumCRC32")
|
||||||
|
resp["ResponseMetadata"]["HTTPHeaders"].should_not.have.key(
|
||||||
|
"x-amz-sdk-checksum-algorithm"
|
||||||
|
)
|
||||||
resp = s3.put_object(
|
resp = s3.put_object(
|
||||||
Bucket="mybucket", Key="1", Body="a", ChecksumAlgorithm="CRC32"
|
Bucket="mybucket", Key="1", Body="a", ChecksumAlgorithm="CRC32"
|
||||||
)
|
)
|
||||||
@ -1416,8 +1421,9 @@ def test_list_objects_v2_checksum_algo():
|
|||||||
].should.equal("SHA256")
|
].should.equal("SHA256")
|
||||||
|
|
||||||
resp = s3.list_objects_v2(Bucket="mybucket")["Contents"]
|
resp = s3.list_objects_v2(Bucket="mybucket")["Contents"]
|
||||||
resp[0].should.have.key("ChecksumAlgorithm").equals(["CRC32"])
|
resp[0].should_not.have.key("ChecksumAlgorithm")
|
||||||
resp[1].should.have.key("ChecksumAlgorithm").equals(["SHA256"])
|
resp[1].should.have.key("ChecksumAlgorithm").equals(["CRC32"])
|
||||||
|
resp[2].should.have.key("ChecksumAlgorithm").equals(["SHA256"])
|
||||||
|
|
||||||
|
|
||||||
@mock_s3
|
@mock_s3
|
||||||
|
Loading…
Reference in New Issue
Block a user