kopia lustrzana https://github.com/micropython/micropython-lib
urequests: Actually implement user-defined headers support.
rodzic
08ebeb537d
commit
c4ee3acba5
|
@ -57,6 +57,12 @@ def request(method, url, data=None, json=None, headers={}, stream=None):
|
|||
s.write(b"%s /%s HTTP/1.0\r\n" % (method, path))
|
||||
if not "Host" in headers:
|
||||
s.write(b"Host: %s\r\n" % host)
|
||||
# Iterate over keys to avoid tuple alloc
|
||||
for k in headers:
|
||||
s.write(k)
|
||||
s.write(b": ")
|
||||
s.write(headers[k])
|
||||
s.write(b"\r\n")
|
||||
if json is not None:
|
||||
assert data is None
|
||||
import ujson
|
||||
|
|
Ładowanie…
Reference in New Issue