Change HTTP/1.0 to HTTP/1.1 in requests Python module#861
Change HTTP/1.0 to HTTP/1.1 in requests Python module#861sgbaird wants to merge 1 commit intomicropython:masterfrom
requests Python module#861Conversation
|
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 Note that our In summary: let's update to HTTP/1.1 but it needs to be done to the spec, and tested well. |
As a temporary workaround to the issue described in https://github.com/orgs/micropython/discussions/15112, add urequests_2.py to your microcontroller, and change import urequests to import urequests_2 as urequests in the code below. See https://github.com/orgs/micropython/discussions/15112 and micropython/micropython-lib#861 for ongoing updates. The corresponding assignment will also be affected, but this can be addressed using the same workaround.
|
I was banging my head against the wall regarding a similar problem I was having with an API. I appreciate you figuring this out; your solution works perfectly for my needs. Thanks again! |
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.0with1.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
masterdue 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.