Skip to content

Commit

Permalink
PR feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
jonathan343 committed Oct 29, 2024
1 parent 5f85f89 commit 75db0fe
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 8 deletions.
4 changes: 2 additions & 2 deletions botocore/httpchecksum.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
MissingDependencyException,
)
from botocore.response import StreamingBody
from botocore.utils import _has_checksum_header, determine_content_length
from botocore.utils import determine_content_length, has_checksum_header

if HAS_CRT:
from awscrt import checksums as crt_checksums
Expand Down Expand Up @@ -259,7 +259,7 @@ def resolve_request_checksum_algorithm(
supported_algorithms=None,
):
# If the header is already set by the customer, skip calculation
if _has_checksum_header(request):
if has_checksum_header(request):
return

request_checksum_calculation = request["context"][
Expand Down
8 changes: 5 additions & 3 deletions botocore/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -3255,7 +3255,9 @@ def _is_s3express_request(params):
return endpoint_properties.get('backend') == 'S3Express'


def _has_checksum_header(params):
# This is not a public interface and is subject to abrupt breaking changes.
# Any usage is not advised or supported in external code bases.
def has_checksum_header(params):
headers = params['headers']

# If a header matching the x-amz-checksum-* pattern is present, we
Expand All @@ -3269,7 +3271,7 @@ def _has_checksum_header(params):

def conditionally_calculate_checksum(params, **kwargs):
"""This function has been deprecated, but is kept for backwards compatibility."""
if not _has_checksum_header(params):
if not has_checksum_header(params):
conditionally_calculate_md5(params, **kwargs)
conditionally_enable_crc32(params, **kwargs)

Expand Down Expand Up @@ -3305,7 +3307,7 @@ def conditionally_calculate_md5(params, **kwargs):
# Skip for requests that will have a flexible checksum applied
return

if _has_checksum_header(params):
if has_checksum_header(params):
# Don't add a new header if one is already available.
return

Expand Down
6 changes: 3 additions & 3 deletions tests/unit/test_httpchecksum.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ def test_request_checksum_algorithm_no_model(self):
resolve_request_checksum_algorithm(request, operation_model, params)
self.assertNotIn("checksum", request["context"])

def test_request_checksum_algorithm_model_opt_in(self):
def test_request_checksum_algorithm_model_default(self):
operation_model = self._make_operation_model(
http_checksum={"requestAlgorithmMember": "Algorithm"}
)
Expand Down Expand Up @@ -142,7 +142,7 @@ def test_request_checksum_algorithm_model_opt_in(self):
resolve_request_checksum_algorithm(request, operation_model, params)
self.assertNotIn("checksum", request["context"])

def test_request_checksum_algorithm_model_opt_in_streaming(self):
def test_request_checksum_algorithm_model_default_streaming(self):
request = self._build_request(b"")
operation_model = self._make_operation_model(
http_checksum={"requestAlgorithmMember": "Algorithm"},
Expand Down Expand Up @@ -395,7 +395,7 @@ def test_response_checksum_algorithm_no_model(self):
resolve_response_checksum_algorithms(request, operation_model, params)
self.assertNotIn("checksum", request["context"])

def test_response_checksum_algorithm_model_opt_in(self):
def test_response_checksum_algorithm_model_default(self):
request = self._build_request(b"")
operation_model = self._make_operation_model(
http_checksum={
Expand Down

0 comments on commit 75db0fe

Please sign in to comment.