Open sgbaird opened 1 month ago
I think it's a good idea to merge this as-is.
However, it would also be useful to take a look at CircuitPython's request library. It was based on this one but has since had some updates - it'd be good to evaluate if other changes should be integrated too.
See related #844.
It's a shame that HTTP/1.0 is becoming obsolete because it's a nice and simple (and still functional) protocol.
But, yeah, we need to update to use HTTP/1.1. The problem is it's not as simple as changing the 1.0
to a 1.1
. The code also needs to be improved to support chunked responses, at the very least. Also probably need to add Accept-Encoding: identity
to the headers to prevent the server from responding with compressed data, which we can't deal with.
Note that our aiohttp
library does support HTTP/1.1, but it's not really a drop-in replacement for requests
.
In summary: let's update to HTTP/1.1 but it needs to be done to the spec, and tested well.
On the Pico W, I'm suddenly having trouble accessing an API that used to be compatible. The issue seems to be the HTTP version, which I documented at https://github.com/orgs/micropython/discussions/15112. As somewhat of a last try, I copied over https://github.com/micropython/micropython-lib/blob/e025c843b60e93689f0f991d753010bb5bd6a722/python-ecosys/requests/requests/__init__.py into a
urequests_2.py
, usedimport urequests_2 as urequests
, and simply replaced1.0
with1.1
:with:
I was able to successfully send data through the API after that. I also wanted to note that I couldn't use the version on
master
due toImportError: no module named 'tls'
, hence the pinned version from above. I have tutorials, videos, and a module within a course dependent on this, so it would be great to have this incorporated into a stable version of Pico W MicroPython if it's feasible.