Don't rely on netloc for determining hostname and port, just use hostname and port (#56270)

* Add changelog fragment
* Fix IPv6 address parsing for py2.6, and add tests
* make sure hostname isn't None
This commit is contained in:
Matt Martz
2019-05-20 15:50:55 -05:00
committed by Sam Doran
parent 66bfa27685
commit 493cf817a9
3 changed files with 33 additions and 13 deletions

View File

@@ -76,6 +76,16 @@ def test_maybe_add_ssl_handler(mocker):
handler = urls.maybe_add_ssl_handler(url, True)
assert handler is None
url = 'https://[2a00:16d8:0:7::205]:4443/'
handler = urls.maybe_add_ssl_handler(url, True)
assert handler.hostname == '2a00:16d8:0:7::205'
assert handler.port == 4443
url = 'https://[2a00:16d8:0:7::205]/'
handler = urls.maybe_add_ssl_handler(url, True)
assert handler.hostname == '2a00:16d8:0:7::205'
assert handler.port == 443
def test_basic_auth_header():
header = urls.basic_auth_header('user', 'passwd')