Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 11 additions & 4 deletions botocore/httpchecksum.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
from botocore.utils import (
conditionally_calculate_md5,
determine_content_length,
get_checksum_header_algorithms,
get_checksum_algorithm_headers,
has_checksum_header,
)

Expand Down Expand Up @@ -495,9 +495,16 @@ def _apply_request_trailer_checksum(request):

def _register_checksum_feature_ids(request):
"""Register feature IDs for checksum algorithms used in the request."""
if algorithm_list := get_checksum_header_algorithms(request):
for algorithm_name in algorithm_list:
_register_checksum_algorithm_feature_id(algorithm_name)
if algorithm_headers := get_checksum_algorithm_headers(request):
for header in algorithm_headers:
header = header.upper()
if header not in (
"X-AMZ-CHECKSUM-ALGORITHM",
"X-AMZ-CHECKSUM-MODE",
"X-AMZ-CHECKSUM-TYPE",
):
algorithm_name = header.removeprefix("X-AMZ-CHECKSUM-")
_register_checksum_algorithm_feature_id(algorithm_name)
return
# If no checksum header exists yet, check the resolved context for
# an algorithm that will be applied later by apply_request_checksum.
Expand Down
10 changes: 5 additions & 5 deletions botocore/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -3301,10 +3301,10 @@ def _is_s3express_request(params):
return endpoint_properties.get('backend') == 'S3Express'


def get_checksum_header_algorithms(params):
def get_checksum_algorithm_headers(params):
"""
Returns the a list of algorithm name if a headers starting with "x-amz-checksum-"
are provided in a request, otherwise returns an empty list.
Returns the a list of header names from the request which start with
"x-amz-checksum-", otherwise returns an empty list.

This function is considered private and subject to abrupt breaking changes or
removal without prior announcement. Please do not use it directly.
Expand All @@ -3317,7 +3317,7 @@ def get_checksum_header_algorithms(params):
for header in headers:
match = CHECKSUM_HEADER_PATTERN.match(header)
if match:
checksum_headers.append(match.group(1))
checksum_headers.append(header)
return checksum_headers


Expand All @@ -3328,7 +3328,7 @@ def has_checksum_header(params):
This function is considered private and subject to abrupt breaking changes or
removal without prior announcement. Please do not use it directly.
"""
return bool(get_checksum_header_algorithms(params))
return bool(get_checksum_algorithm_headers(params))


def conditionally_calculate_checksum(params, **kwargs):
Expand Down