kopia lustrzana https://github.com/micropython/micropython-lib
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
rodzic
2e4a29defc
commit
a2647e316e
|
@ -20,12 +20,12 @@ def urlopen(url, data=None, method="GET"):
|
||||||
host, port = host.split(":", 1)
|
host, port = host.split(":", 1)
|
||||||
port = int(port)
|
port = int(port)
|
||||||
|
|
||||||
ai = usocket.getaddrinfo(host, port)
|
ai = usocket.getaddrinfo(host, port, 0, usocket.SOCK_STREAM)
|
||||||
addr = ai[0][4]
|
ai = ai[0]
|
||||||
|
|
||||||
s = usocket.socket()
|
s = usocket.socket(ai[0], ai[1], ai[2])
|
||||||
try:
|
try:
|
||||||
s.connect(addr)
|
s.connect(ai[-1])
|
||||||
if proto == "https:":
|
if proto == "https:":
|
||||||
s = ussl.wrap_socket(s, server_hostname=host)
|
s = ussl.wrap_socket(s, server_hostname=host)
|
||||||
|
|
||||||
|
|
Ładowanie…
Reference in New Issue