Conversation
Merge "encode:master" into h2_impl
|
^ So that some discussion could be started. |
# Resolved Conflicts: # tests/test_config.py # uvicorn/config.py # uvicorn/protocols/http/h11_impl.py
| trustme | ||
| cryptography | ||
| coverage | ||
| starlette |
There was a problem hiding this comment.
Do we need starlette? What's the idea here?
| "asgiref>=3.3.4", | ||
| "click>=7.*", | ||
| "h11>=0.8", | ||
| "h2>=4.0.0", |
There was a problem hiding this comment.
We want to do the same as httpx: https://github.com/encode/httpx/blob/ab64f7c41fc0fbe638dd586fecf0689c847109bb/setup.py#L66
| # TODO: Implement or Not? | ||
| # https://groups.google.com/a/chromium.org/g/blink-dev/c/K3rYLvmQUBY/m/vOWBKZGoAQAJ 😕 # noqa: E501 |
|
So, I'm neither necessarily for or against this, but I do have an alternate perspective that I think is worth sharing/considering. See the discussion in... #1105 |
|
It may well make sense for us to deliberately limit the scope of Uvicorn to being an HTTP/1.1 server. |
|
@Vibhu-Agarwal Thanks for the effort here, but I think by #1105 we'll highlight hypercorn as the recommendation for HTTP/2. Sorry for taking so long to act here. |
Closes #47
HTTP Parsing
PR #214
It was great! I've picked a lot of stuff from there.
I've mostly worked on extending the PR, removing bugs and modernizing the code.
I've opted to omit a few implementations though, on which I'd like to have some discussion.
Motivation from Hypercorn's code
I also read the hypercorn's code, which has the implementation for HTTP/2 already. I got a pretty good idea of http2's working from there.
priority
It uses priority to build a priority tree and manage the streams.
I haven't yet implemented this in this PR (as it wasn't, in #214). Should we use it?
If we use it, it will also help in implementing code for handling h2 events like
WindowUpdated,PriorityUpdatedandRemoteSettingsChanged(which are currently ignored).stream_buffers
Hypercorn also uses StreamBuffers to handle the data of different streams per connection. This may be due to the fact that h2 doesn't buffer data internally for sending. I'm not sure though, as hypercorn checks the chunk size (before sending) anyway.
I haven't yet implemented this in this PR (as it wasn't, in #214). Should we use it?
Server Push
I wasn't sure if I should go ahead with HTTP Server-Push's implementation or not, as its status is not clear.
Should we support it?
In this PR
Some h2-specific changes in SSL-Context
No websocket support, yet.
Connection: Upgrade(towebocket) request raisesh2.exceptions.ProtocolErrorhere:https://github.com/encode/uvicorn/blob/b683626db3affb51cffd54bc809ba3b662a4119d/uvicorn/protocols/http/h2_impl.py#L219-L221
https://github.com/encode/uvicorn/blob/b683626db3affb51cffd54bc809ba3b662a4119d/uvicorn/protocols/http/h2_impl.py#L111
That will have to be handled here:
https://github.com/encode/uvicorn/blob/b683626db3affb51cffd54bc809ba3b662a4119d/uvicorn/protocols/http/h2_impl.py#L284-L285
Tests
For some reason,
test_h2c_upgrade_requestis causing failure of some un-related tests in Python3.8 and Python3.9 (runs fine in Python <=3.7). Commit 81f21beManual-Testing: I'm not sure how to manually test this one.
Manual-Testing: I tried this with a POST request using curl. It works. I'm not sure how to replicate it in Python or even get raw HTTP request out of it.
HTTPToolsProtocolandH11Protocol,H2Protocolneeds testing for a lot of stuff.get_connected_protocol()a bit) but got messed up with valid raw HTTP/2 requests and SSL-Context passing. Couldn't debug and get it to work.POSTrequest. It kinda worked out. So I've added this one in the PR.I haven't tried broken apps and others with exceptions.
WIP
# TODO: Taskand added some comments for decision-related discussion or missing implementation.h2_impl.pysimilar tohttptools_impl.pyandh11_impl.py.Help Needed
I'm just giving it a go. Hope to complete this soon 🤞
Will need reviews, inputs, tests, ideas and a lot of help from everyone 🤗