Code: Select all
s=socket.socket(); s.connect(ai); s=ssl.wrap_socket(s, server_hostname=host)
Code: Select all
s=socket.socket(); s.connect(ai); s=ssl.wrap_socket(s, server_hostname=host)
Code: Select all
def _request(method, url, data=None):
proto, dummy, host, path=url.split("/", 3); s=0
for i in range(2):
try:
ai=(ipa, 443)
s=socket.socket(); s.connect(ai); s=ssl.wrap_socket(s, server_hostname=host)
s.write(b"%s /%s HTTP/1.0\r\nHost: %s\r\n" % (method, path, host))
if data: s.write(b"Content-Length: %d\r\n" % len(data))
s.write(b"\r\n")
if data: s.write(data)
l=s.readline(); l=l.split(None, 2); status=int(l[1]); reason = ""
if len(l)>2: reason=l[2].rstrip()
while 1:
l=s.readline()
if not l or l==b"\r\n": break
except OSError as e:
if s: print('close socket'); s.close() # eg [Errno 128] ENOTCONN
Which port and board are you using? Which MicroPython version?