-
-
Notifications
You must be signed in to change notification settings - Fork 746
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
WIP: Implement h2 protocol #1026
Closed
Closed
Changes from all commits
Commits
Show all changes
50 commits
Select commit
Hold shift + click to select a range
65dff56
Updated gitignore
Vibhu-Agarwal 700046c
Added (empty) h2_impl.py
Vibhu-Agarwal 773415e
Added some code ... till RequestReceived event
Vibhu-Agarwal 159dd3b
Set basic triggers for event-handlers
Vibhu-Agarwal fef0bea
Fix on_request_received
Vibhu-Agarwal b92c359
Added remaining methods of H2Protocol
Vibhu-Agarwal 1c5d053
Added code for RequestResponseCycle
Vibhu-Agarwal ec4b786
Added some boilerplate for handle_upgrade in h11_impl.py
Vibhu-Agarwal d2f329e
Handling h2c in h11_impl.py (TODO: Similarly in httptools)
Vibhu-Agarwal 086cc29
Handling connection preface in h11_impl.py
Vibhu-Agarwal eb12592
Modify method prototype: H2Protocol - connection_made()
Vibhu-Agarwal d238f26
Fixed connection preface check in h11_impl.py
Vibhu-Agarwal e694792
Added comments regarding missing implementations
Vibhu-Agarwal 00dce01
Reverted .gitignore
Vibhu-Agarwal c03b6e8
Added comments regarding missing implementations
Vibhu-Agarwal 293aaf6
Applied black (linting)
Vibhu-Agarwal 2a6f2dc
Reformatted h2_impl.py
Vibhu-Agarwal 8f6a825
python -m cli_tools.usage
Vibhu-Agarwal 394140a
Added h2 in requirements
Vibhu-Agarwal 5d6dd1b
Added h2-specific SSLContext options in create_ssl_context()
Vibhu-Agarwal 7e96009
Added h2-connection local settings (through config)
Vibhu-Agarwal 3b5c906
h2c handling implementation added in h2_impl.py
Vibhu-Agarwal a8dcf14
Added ECDHE+AESGCM as SSL-Cipher-Suite for h2
Vibhu-Agarwal b683626
Added TODO for Websocket Extended CONNECT
Vibhu-Agarwal 444a359
Merge branch 'master' into h2_impl
Vibhu-Agarwal 4d4de11
Refactor w.r.t. #1034
Vibhu-Agarwal fb90043
Merge branch 'encode:master' into h2_impl
Vibhu-Agarwal 1b2c1f2
Merge 'encode:master' into h2_impl
Vibhu-Agarwal dbfa251
Merge "encode:master" into h2_impl
Vibhu-Agarwal a0deef4
Remove irrelevant return statement
Vibhu-Agarwal 301c171
Merge branch 'encode:master' into h2_impl
Vibhu-Agarwal 96fe3d7
tests: add coverage for create_ssl_context [config.py]
Vibhu-Agarwal b16564b
Merge branch 'encode:master' into h2_impl
Vibhu-Agarwal e7e00db
Fix h2c bug in h11_impl.py
Vibhu-Agarwal 0e7df0a
Refactor w.r.t. #869
Vibhu-Agarwal 59c95bf
Fix bugs (similar to ones in previous commit)
Vibhu-Agarwal f7e5b8b
Merge branch 'encode:master' into h2_impl
Vibhu-Agarwal 7cae838
auto upgrade (h11=>h2), when alpn_protocol == "h2"
Vibhu-Agarwal 56140b9
Added a TODO for a probable implementation done in #929
Vibhu-Agarwal 81f21be
Added a couple of EMPTY tests (h2c & PRI-h2)
Vibhu-Agarwal 0e6ea51
Added test_h2.py with a simple POST request
Vibhu-Agarwal ad3f35f
Remove test_h2c_upgrade_request from test_http.py
Vibhu-Agarwal f4665bb
Fix the STUPID bug that has been freakin me out
Vibhu-Agarwal 49f251a
Please fix!
Vibhu-Agarwal 2741e0f
Remove "handle_upgrade()" from h2_impl.py
Vibhu-Agarwal df02d8c
on the way to fix h2c
Vibhu-Agarwal 1e4bdd9
Merge branch 'encode:master' into h2_impl
Vibhu-Agarwal 4766009
Merge branch 'encode:master' into h2_impl_mm1
Vibhu-Agarwal 59d663a
Merge branch 'encode:master' into h2_impl
Vibhu-Agarwal 919d3f3
Merge branch 'encode:master' into h2_impl
Vibhu-Agarwal File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -47,6 +47,7 @@ def get_packages(package): | |
"asgiref>=3.3.4", | ||
"click>=7.*", | ||
"h11>=0.8", | ||
"h2>=4.0.0", | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We want to do the same as httpx: https://github.com/encode/httpx/blob/ab64f7c41fc0fbe638dd586fecf0689c847109bb/setup.py#L66 |
||
"typing-extensions;" + env_marker_below_38, | ||
] | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
import httpx | ||
import pytest | ||
from starlette.applications import Starlette | ||
from starlette.responses import JSONResponse | ||
from starlette.routing import Route | ||
|
||
from tests.utils import run_server | ||
from uvicorn.config import Config | ||
|
||
|
||
async def homepage(request): | ||
return JSONResponse({"hello": "world"}) | ||
|
||
|
||
app = Starlette( | ||
routes=[ | ||
Route("/", homepage, methods=["GET", "POST"]), | ||
], | ||
) | ||
|
||
|
||
@pytest.mark.asyncio | ||
async def test_run( | ||
tls_ca_ssl_context, tls_ca_certificate_pem_path, tls_ca_certificate_private_key_path | ||
): | ||
config = Config( | ||
app=app, | ||
http="h2", | ||
loop="asyncio", | ||
limit_max_requests=1, | ||
ssl_keyfile=tls_ca_certificate_private_key_path, | ||
ssl_certfile=tls_ca_certificate_pem_path, | ||
ssl_ca_certs=tls_ca_certificate_pem_path, | ||
) | ||
async with run_server(config): | ||
async with httpx.AsyncClient(verify=tls_ca_ssl_context, http2=True) as client: | ||
response = await client.post( | ||
"https://127.0.0.1:8000", data={"hello": "world"} | ||
) | ||
assert response.status_code == 200 | ||
assert response.http_version == "HTTP/2" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we need
starlette
? What's the idea here?