kopia lustrzana https://github.com/micropython/micropython-lib
urllib.urequest: Support explicit port number in a URL.
rodzic
d711719af6
commit
413bebf6c8
|
@ -11,7 +11,12 @@ def urlopen(url, data=None, method="GET"):
|
||||||
if proto != "http:":
|
if proto != "http:":
|
||||||
raise ValueError("Unsupported protocol: " + proto)
|
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]
|
addr = ai[0][4]
|
||||||
s = usocket.socket()
|
s = usocket.socket()
|
||||||
s.connect(addr)
|
s.connect(addr)
|
||||||
|
|
Ładowanie…
Reference in New Issue