urequests: Support HTTP reply lines without textual description.

E.g. "HTTP/1.1 500". RFC7230 seems to formally require at least a space
after the numeric code, but it was reported that some software sends
lines like above nonetheless.

Ref: https://github.com/micropython/micropython-lib/issues/247
pull/236/merge
Paul Sokolovsky 2018-01-14 11:21:23 +02:00
rodzic 4c2c940c13
commit 4d46561a5b
1 zmienionych plików z 7 dodań i 4 usunięć

Wyświetl plik

@ -79,9 +79,12 @@ def request(method, url, data=None, json=None, headers={}, stream=None):
s.write(data)
l = s.readline()
protover, status, msg = l.split(None, 2)
status = int(status)
#print(protover, status, msg)
#print(l)
l = l.split(None, 2)
status = int(l[1])
reason = ""
if len(l) > 2:
reason = l[2].rstrip()
while True:
l = s.readline()
if not l or l == b"\r\n":
@ -98,7 +101,7 @@ def request(method, url, data=None, json=None, headers={}, stream=None):
resp = Response(s)
resp.status_code = status
resp.reason = msg.rstrip()
resp.reason = reason
return resp