kopia lustrzana https://github.com/micropython/micropython-lib
urllib.urequest: If error happens while parsing response headers, close socket.
Because otherwise, user doesn't get any response object, so cannot close socket, and it leaks.pull/208/head
rodzic
cad77291d5
commit
b715ee0cb8
|
@ -22,7 +22,9 @@ def urlopen(url, data=None, method="GET"):
|
|||
|
||||
ai = usocket.getaddrinfo(host, port)
|
||||
addr = ai[0][4]
|
||||
|
||||
s = usocket.socket()
|
||||
try:
|
||||
s.connect(addr)
|
||||
if proto == "https:":
|
||||
s = ussl.wrap_socket(s, server_hostname=host)
|
||||
|
@ -56,5 +58,8 @@ def urlopen(url, data=None, method="GET"):
|
|||
raise ValueError("Unsupported " + l)
|
||||
elif l.startswith(b"Location:"):
|
||||
raise NotImplementedError("Redirects not yet supported")
|
||||
except OSError:
|
||||
s.close()
|
||||
raise
|
||||
|
||||
return s
|
||||
|
|
Ładowanie…
Reference in New Issue