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)
|
||||
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)
|
||||
|
||||
|
|
Ładowanie…
Reference in New Issue