kopia lustrzana https://github.com/micropython/micropython-lib
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/247pull/236/merge
rodzic
4c2c940c13
commit
4d46561a5b
|
@ -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
|
||||
|
||||
|
||||
|
|
Ładowanie…
Reference in New Issue