MCPcopy Create free account
hub / github.com/aws/aws-cli / _host_from_url

Function _host_from_url

awscli/botocore/auth.py:76–92  ·  view source on GitHub ↗
(url)

Source from the content-addressed store, hash-verified

74
75
76def _host_from_url(url):
77 # Given URL, derive value for host header. Ensure that value:
78 # 1) is lowercase
79 # 2) excludes port, if it was the default port
80 # 3) excludes userinfo
81 url_parts = urlsplit(url)
82 host = url_parts.hostname # urlsplit's hostname is always lowercase
83 if is_valid_ipv6_endpoint_url(url):
84 # Enclose IPv6 Literal addresses in
85 # brackets as per RFC 3986 3.2.2.
86 host = f'[{host}]'
87
88 default_ports = {'http': 80, 'https': 443}
89 if url_parts.port is not None:
90 if url_parts.port != default_ports.get(url_parts.scheme):
91 host = '%s:%d' % (host, url_parts.port)
92 return host
93
94
95def _get_body_as_dict(request):

Callers 3

headers_to_signMethod · 0.85

Calls 1

Tested by

no test coverage detected