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

Websocket sansio implementataion #2060

Open
wants to merge 64 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
64 commits
Select commit Hold shift + click to select a range
ca826db
Implement websockets_sans_impl.py
gourav-kandoria Jul 26, 2023
559617b
add surrogate errors in decode
gourav-kandoria Jul 27, 2023
56d2152
fix lint issues
gourav-kandoria Jul 27, 2023
d12e72a
fix mypy failing issues
gourav-kandoria Jul 27, 2023
f24527b
fix lint issues
gourav-kandoria Jul 27, 2023
ba972e0
fix typing issues
gourav-kandoria Jul 27, 2023
b81f762
Fix extension tests failing
gourav-kandoria Jul 27, 2023
0f59f77
Fix extension tests failing
gourav-kandoria Jul 27, 2023
38e1629
correct types import
gourav-kandoria Jul 29, 2023
29d2d09
correct types import and mypy issues
gourav-kandoria Jul 29, 2023
28f2714
fix typo
gourav-kandoria Jul 29, 2023
10933b6
Merge remote-tracking branch 'upstream/master' into websocket-sansio-…
gourav-kandoria Aug 1, 2023
3a72504
Replace ServerConnection with ServerProtocol due to upgradation of we…
gourav-kandoria Aug 1, 2023
1239297
Merge remote-tracking branch 'upstream/master' into websocket-sansio-…
gourav-kandoria Aug 8, 2023
39e3c33
Remove conditional on imports
Kludex Aug 27, 2023
931e78e
Fix typos, and small details
Kludex Aug 27, 2023
3d57661
Refactor small things
Kludex Aug 28, 2023
d76cdc6
Fix linter
Kludex Aug 28, 2023
ca6f63b
Merge branch 'websocket-sansio-implementataion' of https://github.com…
gourav-kandoria Aug 29, 2023
d246cc4
Merge branch 'master' of https://github.com/encode/uvicorn into webso…
gourav-kandoria Aug 29, 2023
aed00c8
Add tests for websocket server for receiving multiple frames
gourav-kandoria Aug 29, 2023
808f951
Remove checking of PONG event after receiving data
gourav-kandoria Aug 29, 2023
803100c
Revert "Remove checking of PONG event after receiving data"
gourav-kandoria Aug 29, 2023
7519e6b
"Remove checking of PONG event after receiving data"
gourav-kandoria Aug 29, 2023
87ad36a
Create WSType on the test suite
Kludex Aug 30, 2023
1048c18
Add WebSocketsSansIOProtocol to the CLI
Kludex Aug 30, 2023
37a686f
Make changes for testing payload max_size limit
gourav-kandoria Sep 1, 2023
4f76f62
Make changes for testing payload max_size limit
gourav-kandoria Sep 4, 2023
cbe36ba
fix lint issue
gourav-kandoria Sep 4, 2023
348b6ac
increase msg size from 11 to 32
gourav-kandoria Sep 4, 2023
48b1d5f
increase client max_limit
gourav-kandoria Sep 5, 2023
12bb2d2
Empty-Commit-to-trigger-pipeline
gourav-kandoria Sep 5, 2023
498eaf5
Implement websockets_sans_impl.py
gourav-kandoria Jul 26, 2023
e378770
add surrogate errors in decode
gourav-kandoria Jul 27, 2023
3ce1611
fix lint issues
gourav-kandoria Jul 27, 2023
4f601dc
fix mypy failing issues
gourav-kandoria Jul 27, 2023
d48f8c1
fix lint issues
gourav-kandoria Jul 27, 2023
ab12969
fix typing issues
gourav-kandoria Jul 27, 2023
65057b8
Fix extension tests failing
gourav-kandoria Jul 27, 2023
b81bd5a
Fix extension tests failing
gourav-kandoria Jul 27, 2023
63e6f68
correct types import
gourav-kandoria Jul 29, 2023
b89d732
correct types import and mypy issues
gourav-kandoria Jul 29, 2023
526fe56
fix typo
gourav-kandoria Jul 29, 2023
0699a7e
Replace ServerConnection with ServerProtocol due to upgradation of we…
gourav-kandoria Aug 1, 2023
82f3f6e
Remove conditional on imports
Kludex Aug 27, 2023
7a90b8b
Fix typos, and small details
Kludex Aug 27, 2023
e72cd54
Refactor small things
Kludex Aug 28, 2023
d9a4ea0
Fix linter
Kludex Aug 28, 2023
252bdc1
Add tests for websocket server for receiving multiple frames
gourav-kandoria Aug 29, 2023
9ff1a2e
Remove checking of PONG event after receiving data
gourav-kandoria Aug 29, 2023
bc35b4f
Revert "Remove checking of PONG event after receiving data"
gourav-kandoria Aug 29, 2023
b82a8ce
"Remove checking of PONG event after receiving data"
gourav-kandoria Aug 29, 2023
09d3072
Create WSType on the test suite
Kludex Aug 30, 2023
5a22d00
Add WebSocketsSansIOProtocol to the CLI
Kludex Aug 30, 2023
5f5f5f4
Make changes for testing payload max_size limit
gourav-kandoria Sep 1, 2023
8dcd505
Make changes for testing payload max_size limit
gourav-kandoria Sep 4, 2023
3f4eecb
fix lint issue
gourav-kandoria Sep 4, 2023
60460f9
increase msg size from 11 to 32
gourav-kandoria Sep 4, 2023
78c6941
increase client max_limit
gourav-kandoria Sep 5, 2023
0ade3d4
Empty-Commit-to-trigger-pipeline
gourav-kandoria Sep 5, 2023
db31c56
Use WSProtocolType
Kludex Dec 26, 2023
bf00ada
Use future annotations on websocket sansio implementation
Kludex Dec 26, 2023
64d6eb7
WIP websockets denial response extension
Kludex Dec 26, 2023
064a7fc
Merge branch 'websocket-sansio-implementataion' of https://github.com…
gourav-kandoria Dec 26, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion docs/deployment.md
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ Options:
--loop [auto|asyncio|uvloop] Event loop implementation. [default: auto]
--http [auto|h11|httptools] HTTP protocol implementation. [default:
auto]
--ws [auto|none|websockets|wsproto]
--ws [auto|none|websockets|websockets-sansio|wsproto]
WebSocket protocol implementation.
[default: auto]
--ws-max-size INTEGER WebSocket max size message in bytes
Expand Down
2 changes: 1 addition & 1 deletion docs/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ Options:
--loop [auto|asyncio|uvloop] Event loop implementation. [default: auto]
--http [auto|h11|httptools] HTTP protocol implementation. [default:
auto]
--ws [auto|none|websockets|wsproto]
--ws [auto|none|websockets|websockets-sansio|wsproto]
WebSocket protocol implementation.
[default: auto]
--ws-max-size INTEGER WebSocket max size message in bytes
Expand Down
2 changes: 1 addition & 1 deletion docs/settings.md
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ Using Uvicorn with watchfiles will enable the following options (which are other

* `--loop <str>` - Set the event loop implementation. The uvloop implementation provides greater performance, but is not compatible with Windows or PyPy. **Options:** *'auto', 'asyncio', 'uvloop'.* **Default:** *'auto'*.
* `--http <str>` - Set the HTTP protocol implementation. The httptools implementation provides greater performance, but it not compatible with PyPy. **Options:** *'auto', 'h11', 'httptools'.* **Default:** *'auto'*.
* `--ws <str>` - Set the WebSockets protocol implementation. Either of the `websockets` and `wsproto` packages are supported. Use `'none'` to ignore all websocket requests. **Options:** *'auto', 'none', 'websockets', 'wsproto'.* **Default:** *'auto'*.
* `--ws <str>` - Set the WebSockets protocol implementation. Either of the `websockets` and `wsproto` packages are supported. Use `'none'` to ignore all websocket requests. **Options:** *'auto', 'none', 'websockets', 'websockets-sansio', 'wsproto'.* **Default:** *'auto'*.
* `--ws-max-size <int>` - Set the WebSockets max message size, in bytes. Please note that this can be used only with the default `websockets` protocol.
* `--ws-max-queue <int>` - Set the maximum length of the WebSocket incoming message queue. Please note that this can be used only with the default `websockets` protocol.
* `--ws-ping-interval <float>` - Set the WebSockets ping interval, in seconds. Please note that this can be used only with the default `websockets` protocol. **Default:** *20.0*
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ omit = [

[tool.coverage.report]
precision = 2
fail_under = 98.35
fail_under = 98.65
show_missing = true
skip_covered = true
exclude_lines = [
Expand Down
1 change: 1 addition & 0 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -255,6 +255,7 @@ def unused_tcp_port() -> int:
),
),
"uvicorn.protocols.websockets.websockets_impl:WebSocketProtocol",
"uvicorn.protocols.websockets.websockets_sansio_impl:WebSocketsSansIOProtocol",
]
)
def ws_protocol_cls(request: pytest.FixtureRequest):
Expand Down
9 changes: 8 additions & 1 deletion tests/middleware/test_logging.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
from __future__ import annotations

import contextlib
import logging
import socket
Expand All @@ -14,8 +16,13 @@

if typing.TYPE_CHECKING:
from uvicorn.protocols.websockets.websockets_impl import WebSocketProtocol
from uvicorn.protocols.websockets.websockets_sansio_impl import (
WebSocketsSansIOProtocol,
)
from uvicorn.protocols.websockets.wsproto_impl import WSProtocol

WSType = typing.Type["WSProtocol | WebSocketProtocol | WebSocketsSansIOProtocol"]


@contextlib.contextmanager
def caplog_for_logger(caplog, logger_name):
Expand Down Expand Up @@ -87,7 +94,7 @@ async def test_trace_logging_on_http_protocol(

@pytest.mark.anyio
async def test_trace_logging_on_ws_protocol(
ws_protocol_cls: "typing.Type[WSProtocol | WebSocketProtocol]",
ws_protocol_cls: WSType,
caplog,
logging_config,
unused_tcp_port: int,
Expand Down
Loading
Loading