-
Notifications
You must be signed in to change notification settings - Fork 40
Send an empty payload for NO_STATUS_RCVD #153
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
Conversation
e5a2b94
to
e2acfc4
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If I understand correctly the 1005 (NO_STATUS_RCVD) should not be sent, but rather should be substituted if there is no status code (on received close frames).
I wonder if instead of this change the function should it raise a ValueError
if the code passed in is NO_STATUS_RCVD
on the basis that it can already send empty frames (code=None) and trying to explicitly send this code is an odd thing to do.
if code is None and reason is not None: | ||
if code is CloseReason.NO_STATUS_RCVD: | ||
code = None | ||
if code is None and reason: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you change to reason is not None
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
wsproto currently generates CloseConnection events with an empty string as the payload.
wsproto/src/wsproto/frame_protocol.py
Line 529 in 38716a9
reason = data[2:].decode("utf-8") |
Would you prefer if we change that to a
None
payload?
Yes. The current behavior is that if one tries to send a 1005, it is silently substituted with a 1000. My proposal is to change that to not sending a status code instead. It would definitely be wrong to send an actual status code of 1005 on the wire. The problem at its core is that wsproto currently uses the special value At the moment the CloseConnection also does not declare Lines 181 to 182 in 38716a9
My proposal would be we consistently use one special value ( |
I've merged manually with a slight change to the reason None checking - as |
Awesome, thanks for getting back at this! |
This was originally per #153 but I felt it didn't make sense to change. However, it does and without this change the autobahn tests fail.
The reason change did in the end make sense (to keep the autobahn tests passing), have re-added in d970644. |
currently emits a close frame with status code 1000 (NORMAL_CLOSURE) instead of not sending a payload. This PR fixes this.
NO_STATUS_RCVD
should probably be more generally calledNO_STATUS_CODE
, but that would unnecessarily break compatibility.