kopia lustrzana https://github.com/micropython/micropython-lib
urequests: Support explicit port number in a URL.
rodzic
7d211421cb
commit
7862b6df44
|
@ -39,7 +39,12 @@ def request(method, url, data=None, json=None, headers={}, stream=None):
|
||||||
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