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

Add reason to WebSocket closure #1417

Merged
merged 20 commits into from
Jan 22, 2022
Merged

Add reason to WebSocket closure #1417

merged 20 commits into from
Jan 22, 2022

Conversation

aminalaee
Copy link
Member

@aminalaee aminalaee commented Jan 15, 2022

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.

tests/test_websockets.py Outdated Show resolved Hide resolved
Copy link
Member

@Kludex Kludex left a comment

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.

docs/websockets.md Outdated Show resolved Hide resolved
starlette/websockets.py Outdated Show resolved Hide resolved
starlette/websockets.py Outdated Show resolved Hide resolved
starlette/websockets.py Outdated Show resolved Hide resolved
starlette/websockets.py Outdated Show resolved Hide resolved
aminalaee and others added 3 commits January 15, 2022 19:49
Co-authored-by: Marcelo Trylesinski <marcelotryle@gmail.com>
@aminalaee aminalaee requested a review from Kludex January 17, 2022 18:36
starlette/websockets.py Outdated Show resolved Hide resolved
tests/test_websockets.py Outdated Show resolved Hide resolved
starlette/websockets.py Outdated Show resolved Hide resolved
Copy link
Member

@Kludex Kludex left a comment

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! 🎉

starlette/testclient.py Outdated Show resolved Hide resolved
aminalaee and others added 2 commits January 22, 2022 12:03
Co-authored-by: Marcelo Trylesinski <marcelotryle@gmail.com>
@aminalaee aminalaee mentioned this pull request Jan 22, 2022
8 tasks
@aminalaee aminalaee merged commit 34d9f0f into encode:master Jan 22, 2022
@aminalaee aminalaee deleted the add-websocket-close-reason branch January 22, 2022 16:11
adriangb added a commit to Kludex/starlette that referenced this pull request Jan 27, 2022
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