From f8e01a6f2da667815ffbd7f2cdb6e80fa879aae2 Mon Sep 17 00:00:00 2001 From: Jonas Neubert Date: Tue, 9 May 2023 13:22:16 -0600 Subject: [PATCH] Revert "consolidate repeated code in _convert_to_request_dict" This reverts commit bd4452461678a26b57cb8ccf1db9802f1fda8109. --- botocore/client.py | 26 +++++++++++--------------- botocore/signers.py | 28 ++++++++++++++++++++++++++-- 2 files changed, 37 insertions(+), 17 deletions(-) diff --git a/botocore/client.py b/botocore/client.py index 390f06c02a..7180779414 100644 --- a/botocore/client.py +++ b/botocore/client.py @@ -912,10 +912,20 @@ def _make_api_call(self, operation_name, api_params): 'has_streaming_input': operation_model.has_streaming_input, 'auth_type': operation_model.auth_type, } + api_params = self._emit_api_params( + api_params=api_params, + operation_model=operation_model, + context=request_context, + ) + endpoint_url, additional_headers = self._resolve_endpoint_ruleset( + operation_model, api_params, request_context + ) request_dict = self._convert_to_request_dict( api_params=api_params, operation_model=operation_model, + endpoint_url=endpoint_url, context=request_context, + headers=additional_headers, ) resolve_checksum_context(request_dict, operation_model, api_params) @@ -973,23 +983,11 @@ def _convert_to_request_dict( self, api_params, operation_model, - endpoint_url=None, + endpoint_url, context=None, headers=None, set_user_agent_header=True, - ignore_signing_region=False, ): - api_params = self._emit_api_params( - api_params=api_params, - operation_model=operation_model, - context=context, - ) - endpoint_url, additional_headers = self._resolve_endpoint_ruleset( - operation_model=operation_model, - params=api_params, - request_context=context, - ignore_signing_region=ignore_signing_region, - ) request_dict = self._serializer.serialize_to_request( api_params, operation_model ) @@ -997,8 +995,6 @@ def _convert_to_request_dict( request_dict.pop('host_prefix', None) if headers is not None: request_dict['headers'].update(headers) - if additional_headers is not None: - request_dict['headers'].update(additional_headers) if set_user_agent_header: user_agent = self._client_config.user_agent else: diff --git a/botocore/signers.py b/botocore/signers.py index 3d82158e56..8ff0fdd1b2 100644 --- a/botocore/signers.py +++ b/botocore/signers.py @@ -657,12 +657,24 @@ def generate_presigned_url( operation_model = self.meta.service_model.operation_model(operation_name) bucket_is_arn = ArnParser.is_arn(params.get('Bucket', '')) + endpoint_url, additional_headers = self._resolve_endpoint_ruleset( + operation_model, + params, + context, + ignore_signing_region=(not bucket_is_arn), + ) + params = self._emit_api_params( + api_params=params, + operation_model=operation_model, + context=context, + ) request_dict = self._convert_to_request_dict( api_params=params, operation_model=operation_model, + endpoint_url=endpoint_url, context=context, + headers=additional_headers, set_user_agent_header=False, - ignore_signing_region=(not bucket_is_arn), ) # Switch out the http method if user specified it. @@ -772,12 +784,24 @@ def generate_presigned_post( operation_model = self.meta.service_model.operation_model('CreateBucket') params = {'Bucket': bucket} bucket_is_arn = ArnParser.is_arn(params.get('Bucket', '')) + endpoint_url, additional_headers = self._resolve_endpoint_ruleset( + operation_model, + params, + context, + ignore_signing_region=(not bucket_is_arn), + ) + params = self._emit_api_params( + api_params=params, + operation_model=operation_model, + context=context, + ) request_dict = self._convert_to_request_dict( api_params=params, operation_model=operation_model, + endpoint_url=endpoint_url, context=context, + headers=additional_headers, set_user_agent_header=False, - ignore_signing_region=(not bucket_is_arn), ) # Append that the bucket name to the list of conditions.