-
-
Notifications
You must be signed in to change notification settings - Fork 432
proto: provide reason when refusing connections #2235
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
base: main
Are you sure you want to change the base?
Conversation
pub fn refuse_reason( | ||
&mut self, | ||
incoming: Incoming, | ||
reason: Option<String>, |
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.
Connection::close
takes Bytes
. Should we do the same here?
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.
Why? ApplicationClose::reason
is (publicly) Bytes
but TransportError::reason
is (publicly) String
-- I feel like String
is probably more reasonable in terms of the public API, and it doesn't feel like there's a bunch of performance to be had from refcounting error reasons instead of allocating?
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.
It gets baked down into ConnectionClose::reason
, which exactly mirrors ApplicationClose::reason
as Bytes
, and is not strictly required to be UTF-8. The involvement of TransportError
is an artifact of the private initial_close
API, which we can easily revisit. Most important, though, is just that it would be more consistent with close
, which is morally the same operation, just at a different time.
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.
- Reason Phrase: Additional diagnostic information for the closure. This can be zero length if the sender chooses not to give details beyond the Error Code value. This SHOULD be a UTF-8 encoded string [RFC3629], though the frame does not carry information, such as language tags, that would aid comprehension by any entity other than the one that created the text.
Which makes me feel that String
is a better API than Bytes
.
@gretchenfrage you mentioned you want to review this -- friendly ping? |
Sorry, I hadn't meant to block this as long as I have! I'll try not to much longer. |
No description provided.