Skip to content

Commit

Permalink
Revert "consolidate repeated code in _convert_to_request_dict"
Browse files Browse the repository at this point in the history
This reverts commit bd44524.
  • Loading branch information
jonemo committed May 9, 2023
1 parent e4c89a5 commit 878cd84
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 18 deletions.
26 changes: 11 additions & 15 deletions botocore/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down Expand Up @@ -973,32 +983,18 @@ 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
)
if not self._client_config.inject_host_prefix:
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:
Expand Down
29 changes: 26 additions & 3 deletions botocore/signers.py
Original file line number Diff line number Diff line change
Expand Up @@ -656,13 +656,25 @@ def generate_presigned_url(
raise UnknownClientMethodError(method_name=client_method)

operation_model = self.meta.service_model.operation_model(operation_name)
params = self._emit_api_params(
api_params=params,
operation_model=operation_model,
context=context,
)
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),
)
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.
Expand Down Expand Up @@ -770,14 +782,25 @@ def generate_presigned_post(
# We choose the CreateBucket operation model because its url gets
# serialized to what a presign post requires.
operation_model = self.meta.service_model.operation_model('CreateBucket')
params = {'Bucket': bucket}
params = self._emit_api_params(
api_params={'Bucket': bucket},
operation_model=operation_model,
context=context,
)
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),
)
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.
Expand Down

0 comments on commit 878cd84

Please sign in to comment.