Skip to content

Add reason to WebSocket closure - #1417

Merged
aminalaee merged 20 commits into
Kludex:masterfrom
aminalaee:add-websocket-close-reason
Jan 22, 2022
Merged

aminalaee merged 20 commits into
Kludex:masterfrom
aminalaee:add-websocket-close-reason

Conversation

@aminalaee

@aminalaee aminalaee commented Jan 15, 2022

Copy link
Copy Markdown
Contributor

Closes #991.

According to the ASGI spec here reason can be included in websocket.close which is an optional string.

I think what @Kludex mentioned here makes sense:

- We can include code in websocket.close only when it's specified in Starlette, and don't include it when not set, as per the ASGI spec it is optional int and already handled by Uvicorn here and Daphne here and Hypercorn here.

  • We will include reason in websocket.close only when it's specified as per the ASGI spec it's optional and will be handled by ASGI servers.

Any feedback would be appreciated.

Comment thread tests/test_websockets.py Outdated

@Kludex Kludex left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I understand the default value change on code, but that is another issue, and it's also considered a breaking change.

Comment thread docs/websockets.md Outdated
Comment thread starlette/websockets.py Outdated
Comment thread starlette/websockets.py Outdated
Comment thread starlette/websockets.py Outdated
Comment thread starlette/websockets.py Outdated
@aminalaee
aminalaee requested a review from Kludex January 17, 2022 18:36
Comment thread starlette/websockets.py Outdated
Comment thread tests/test_websockets.py Outdated
Comment thread starlette/websockets.py Outdated

@Kludex Kludex left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added a comment, but your call.

Everything is cool 馃憤 Thanks! 馃帀

Comment thread starlette/testclient.py Outdated
aminalaee and others added 2 commits January 22, 2022 12:03
@aminalaee aminalaee mentioned this pull request Jan 22, 2022
8 tasks
@aminalaee
aminalaee merged commit 34d9f0f into Kludex:master Jan 22, 2022
@aminalaee
aminalaee deleted the add-websocket-close-reason branch January 22, 2022 16:11
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.

[Feature] Reason for websocket.close

2 participants