This removes all the hard-coded request headers from the requests module so
they can be overridden by user provided headers dict. Furthermore allow
streaming request data without chunk encoding in those cases where content
length is known but it's not desirable to load the whole content into
memory. Also some servers (e.g. nginx) reject HTTP/1.0 requests with the
Transfer-Encoding header set.
The change should be backwards compatible as long as the user hasn't
provided any of the previously hard-coded headers.
Signed-off-by: Mirza Kapetanovic <mirza.kapetanovic@gmail.com>
MicroPython now supplies SSL/TLS functionality in a new built-in `tls`
module. The `ssl` module is now implemented purely in Python, in this
repository. Other libraries are updated to work with this scheme.
Signed-off-by: Felix Dörre <felix@dogcraft.de>
Chunked detection does not work as generators never have an `__iter__`
attribute. They do have `__next__`.
Example that now works with this commit:
def read_in_chunks(file_object, chunk_size=4096):
while True:
data = file_object.read(chunk_size)
if not data:
break
yield data
file = open(filename, "rb")
r = requests.post(url, data=read_in_chunks(file))
This module implements a subset of the Python requests module, and so
it should have the same name.
Added a backwards-compatibility wrapper to allow people to continue to use
`import urequests`. This lives in micropython/urequests.
Changed requests to be a package, so that we can implement extension
packages in the future for optional functionality.
Added a basic README.md to both.
This work was funded through GitHub Sponsors.
Signed-off-by: Jim Mussared <jim.mussared@gmail.com>