(endpoint_url, url_path, host_prefix)
| 315 | |
| 316 | |
| 317 | def _urljoin(endpoint_url, url_path, host_prefix): |
| 318 | p = urlsplit(endpoint_url) |
| 319 | # <part> - <index> |
| 320 | # scheme - p[0] |
| 321 | # netloc - p[1] |
| 322 | # path - p[2] |
| 323 | # query - p[3] |
| 324 | # fragment - p[4] |
| 325 | if not url_path or url_path == '/': |
| 326 | # If there's no path component, ensure the URL ends with |
| 327 | # a '/' for backwards compatibility. |
| 328 | if not p[2]: |
| 329 | new_path = '/' |
| 330 | else: |
| 331 | new_path = p[2] |
| 332 | elif p[2].endswith('/') and url_path.startswith('/'): |
| 333 | new_path = p[2][:-1] + url_path |
| 334 | else: |
| 335 | new_path = p[2] + url_path |
| 336 | |
| 337 | new_netloc = p[1] |
| 338 | if host_prefix is not None: |
| 339 | new_netloc = host_prefix + new_netloc |
| 340 | |
| 341 | reconstructed = urlunsplit((p[0], new_netloc, new_path, p[3], p[4])) |
| 342 | return reconstructed |
| 343 | |
| 344 | |
| 345 | class AWSRequestPreparer: |
no outgoing calls
no test coverage detected