urllib.urequest: Be sure to create socket with params returned by getaddrinfo().

To use address as returned by getaddrinfo(), we should create a socket
compatible with address family, etc., returned by the same call alongside
the address itself.
pull/255/merge
Paul Sokolovsky 2018-01-23 00:26:38 +02:00
rodzic 2e4a29defc
commit a2647e316e
1 zmienionych plików z 4 dodań i 4 usunięć

Wyświetl plik

@ -20,12 +20,12 @@ def urlopen(url, data=None, method="GET"):
host, port = host.split(":", 1)
port = int(port)
ai = usocket.getaddrinfo(host, port)
addr = ai[0][4]
ai = usocket.getaddrinfo(host, port, 0, usocket.SOCK_STREAM)
ai = ai[0]
s = usocket.socket()
s = usocket.socket(ai[0], ai[1], ai[2])
try:
s.connect(addr)
s.connect(ai[-1])
if proto == "https:":
s = ussl.wrap_socket(s, server_hostname=host)