This method prepares a request dict to be created into an AWSRequestObject. This prepares the request dict by adding the url and the user agent to the request dict. :type request_dict: dict :param request_dict: The request dict (created from the ``serialize`` module).
(
request_dict, endpoint_url, context=None, user_agent=None
)
| 249 | |
| 250 | |
| 251 | def prepare_request_dict( |
| 252 | request_dict, endpoint_url, context=None, user_agent=None |
| 253 | ): |
| 254 | """ |
| 255 | This method prepares a request dict to be created into an |
| 256 | AWSRequestObject. This prepares the request dict by adding the |
| 257 | url and the user agent to the request dict. |
| 258 | |
| 259 | :type request_dict: dict |
| 260 | :param request_dict: The request dict (created from the |
| 261 | ``serialize`` module). |
| 262 | |
| 263 | :type user_agent: string |
| 264 | :param user_agent: The user agent to use for this request. |
| 265 | |
| 266 | :type endpoint_url: string |
| 267 | :param endpoint_url: The full endpoint url, which contains at least |
| 268 | the scheme, the hostname, and optionally any path components. |
| 269 | """ |
| 270 | r = request_dict |
| 271 | if user_agent is not None: |
| 272 | headers = r['headers'] |
| 273 | headers['User-Agent'] = user_agent |
| 274 | host_prefix = r.get('host_prefix') |
| 275 | url = _urljoin(endpoint_url, r['url_path'], host_prefix) |
| 276 | if r['query_string']: |
| 277 | # NOTE: This is to avoid circular import with utils. This is being |
| 278 | # done to avoid moving classes to different modules as to not cause |
| 279 | # breaking chainges. |
| 280 | percent_encode_sequence = botocore.utils.percent_encode_sequence |
| 281 | encoded_query_string = percent_encode_sequence(r['query_string']) |
| 282 | if '?' not in url: |
| 283 | url += f'?{encoded_query_string}' |
| 284 | else: |
| 285 | url += f'&{encoded_query_string}' |
| 286 | r['url'] = url |
| 287 | r['context'] = context |
| 288 | if context is None: |
| 289 | r['context'] = {} |
| 290 | |
| 291 | |
| 292 | def create_request_object(request_dict): |