Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

urequests still using HTTP/1.0 #844

Open
linusoft opened this issue Apr 11, 2024 · 3 comments
Open

urequests still using HTTP/1.0 #844

linusoft opened this issue Apr 11, 2024 · 3 comments

Comments

@linusoft
Copy link

linusoft commented Apr 11, 2024

The urequests module is still using HTTP/1.0 for HTTP requests:

line 39 in micropython-lib/micropython/urllib.urequest/urllib/urequest.py on the master branch:

s.write(b" HTTP/1.0\r\nHost: ")

Since a host header is included, can this be updated to use HTTP/1.1 or even HTTP/2.0?

Some sites (e.g. mongodb) are now responding with '426 Update Required' for HTTP/1.0 requests.

Thanks

@th4ruka
Copy link

th4ruka commented May 5, 2024

Hey! I also think it is better to update the header in line 39 of micropython-lib/micropython/urllib.urequest/urllib/urequest.py as,

- s.write(b" HTTP/1.0\r\nHost: ")
+ s.write(b" HTTP/2.0\r\nHost: ") 

As I know, most major web servers and CDNs provide backward compatibility. Therefore there will be no harm by updating it.

@sosi-deadeye
Copy link

HTTP/2 is a binary protocol and uses HPACK for header compression. Changing this, require additional code to handle the protocol and header compression.

I also think the change to HTTP/1.1 may require some additional code, to handle the different connection types : close, keep-alive.

In addition, there are different Transfer-Endocings.

@mattytrentini
Copy link
Contributor

It would be good to merge back some of the changes from the CircuitPython requests library (they've updated it since originally starting with the MicroPython implementation). In it, they respond with v1.1, though I'm not sure it 100% conforms to spec...

https://github.com/adafruit/Adafruit_CircuitPython_Requests/blob/main/adafruit_requests.py

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants