urllib.urequest: Support explicit port number in a URL.

pull/75/head
Paul Sokolovsky 2016-05-25 00:05:10 +03:00
rodzic d711719af6
commit 413bebf6c8
1 zmienionych plików z 6 dodań i 1 usunięć

Wyświetl plik

@ -11,7 +11,12 @@ def urlopen(url, data=None, method="GET"):
if proto != "http:":
raise ValueError("Unsupported protocol: " + proto)
ai = usocket.getaddrinfo(host, 80)
port = 80
if ":" in host:
host, port = host.split(":", 1)
port = int(port)
ai = usocket.getaddrinfo(host, port)
addr = ai[0][4]
s = usocket.socket()
s.connect(addr)