Skip to content

Allow empty WebSocket frames in WebsocketCommunicator - #2234

Open
zhechen-cs wants to merge 1 commit into
django:mainfrom
zhechen-cs:codex/allow-empty-websocket-frames
Open

zhechen-cs wants to merge 1 commit into
django:mainfrom
zhechen-cs:codex/allow-empty-websocket-frames

Conversation

@zhechen-cs

Copy link
Copy Markdown

WebsocketCommunicator.send_to() uses payload truthiness to decide whether text or bytes was supplied. As a result it rejects both text_data="" and bytes_data=b"", even though the consumers can handle and echo those messages. It also accepts both arguments when one is empty.

Check for None instead, preserving the requirement that exactly one payload is supplied. Add round-trip tests for empty text and binary messages, plus the invalid argument combinations.

Validation: pytest -q tests/test_testing.py (15 passed); flake8, black and isort checks passed.

The full run had 87 passing tests and two Selenium failures waiting for window.websocketConnected. A clean upstream checkout also fails in that Selenium group (81 passed, one failed); the two browser tests pass when run alone on upstream. The failed full runs are retained locally.

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

Successfully merging this pull request may close these issues.

1 participant