-
Notifications
You must be signed in to change notification settings - Fork 3.7k
pywebsocket3 vs. websockets #28863
Copy link
Copy link
Closed
Description
We currently use two different Python libraries for WebSockets:
- pywebsocket3. This is what is used in wptserve and websockets/handlers/ to test the WebSockets protocol itself.
- websockets, recently introduced for testing WebDriver BiDi. It's designed for using WebSockets rather than testing it, and is probably not as easy to use for sending deliberately invalid data.
Both are vendored into tools/third_party/.
Note that even with pywebsocket3 we're using "private" APIs:
wpt/tools/wptserve/wptserve/ws_h2_handshake.py
Lines 15 to 26 in 6a96f5c
| # TODO: We are using "private" methods of pywebsocket. We might want to | |
| # refactor pywebsocket to expose those methods publicly. Also, _get_origin | |
| # _check_version _set_protocol _parse_extensions and a large part of do_handshake | |
| # are identical with hybi handshake. We need some refactoring to get remove that | |
| # code duplication. | |
| from mod_pywebsocket.extensions import get_extension_processor | |
| from mod_pywebsocket.handshake._base import get_mandatory_header | |
| from mod_pywebsocket.handshake._base import HandshakeException | |
| from mod_pywebsocket.handshake._base import parse_token_list | |
| from mod_pywebsocket.handshake._base import validate_mandatory_header | |
| from mod_pywebsocket.handshake._base import validate_subprotocol | |
| from mod_pywebsocket.handshake._base import VersionException |
And note that with WebDriver BiDi, we'll also want to have the ability to send some invalid messages, such as text messages that aren't valid UTF-8.
Has anyone looked into these libraries in detail? Is there a possible path where we can have just one library which is patchable enough for all of our needs?
cc @web-platform-tests/wpt-core-team + websockets/ folks @jdm @ricea @zqzhang
Reactions are currently unavailable