-
Notifications
You must be signed in to change notification settings - Fork 83
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 SecWebsocketExtensions
#88
base: master
Are you sure you want to change the base?
Conversation
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.
Thanks for the PR!
Does this type by itself provide any use? I imagine you need to do more with it than simply materialize an opaque value from the map.
This comment has been minimized.
This comment has been minimized.
b60896b
to
ff67b0b
Compare
c6ee5f0
to
16e387a
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.
Wow, this is a lot of work, thanks for putting so much thought into this!
/// [RFC6455_11.3.2]: https://tools.ietf.org/html/rfc6455#section-11.3.2 | ||
/// [RFC7692_7]: https://tools.ietf.org/html/rfc7692#section-7 | ||
#[derive(Clone, Debug, Eq, PartialEq)] | ||
pub struct SecWebsocketExtensions(pub Vec<WebsocketExtension>); |
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.
We should keep the fields private, so we can change the internal implementation whenever desired.
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.
I explained the reason behind this in #88 (comment)
|
||
/// A WebSocket extension containing the name and parameters. | ||
#[derive(Clone, Debug, Eq, PartialEq)] | ||
pub struct WebsocketExtension { |
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.
This just a thought, let me know what you think. What if this type simply held a reference, instead of individual owned value strings and a vector of params? The name
and params
methods could return "lazy" values, as a few of the other headers in this crate already do.
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.
I actually had struct SecWebsocketExtensions(HeaderValueString);
with lazy iter()
originally. But I wanted decode
to fail on values with invalid syntax, so typed_try_get
can be used to detect them. This requires parsing the values, so I thought it was better to store the result.
The main reason this can be useful is, when negotiating extensions, values with invalid syntax must be rejected:
If a value is received by either the client or the server during negotiation that does not conform to the ABNF below, the recipient of such malformed data MUST immediately Fail the WebSocket Connection.
If we validate the syntax in decode
, crates using headers
can focus on the parameters for each extension, and warp
can reject the invalid headers, etc..
Also, having WebsocketExtension
independent is useful because the server needs to filter them, and respond with potentially mutated versions (e.g., parameter ("client_max_window_bits", Some("10"))
may be changed to have value Some("9")
in the response). WebsocketExtension
can provide setters/builder that makes sure that the value won't result in invalid syntax.
This is why I made the field and the struct public, but I can try to come up with something else if this is an issue.
|
||
/// An iterator over the `WebsocketExtension`s in `SecWebsocketExtensions` header(s). | ||
pub fn iter(&self) -> impl Iterator<Item = &WebsocketExtension> { | ||
self.0.iter() |
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.
Similar question here, what if instead of owning a Vec
, the return iterator were lazy, and did the parsing as requested on each call to next
, like other headers?
50ae3d2
to
f6fb712
Compare
f6fb712
to
a7c0056
Compare
I'd like to take over pushing Which review points have to be addressed in order to get this PR merged? |
@ilammy I was waiting on a response from @seanmonstar for #88 (comment). Once this is merged, I already have a branch using it, which is a rebased version of my original tungstenite-rs PR. |
@kazk @seanmonstar I'm humble ask to return to review this PR as dependent functionality in tungstenite-rs extremely important for my team, but in same time we have strict policy don't use libraries from branches, so we have to wait for finalized published version. |
@gallowsmaker I can't do anything for this PR, but I'll open a new PR for I've been using the original version in production without any issues, but I'd love to get these merged and move on. |
2177abb
to
a7c0056
Compare
54fd7a1
to
b9cfe47
Compare
@seanmonstar just checking if you're still able to review this? |
It would be super nice to get this merged - any hope for this to progress? |
This comment was marked as spam.
This comment was marked as spam.
@seanmonstar @kazk bump. What's the blocker here? What help do you need? |
This comment was marked as spam.
This comment was marked as spam.
This comment was marked as spam.
This comment was marked as spam.
I need use SecWebsocketExtensions hyperium#88 , but it not merge, pub util so I can copy the file to my project without merge it into headers , the file need util is public
This PR is highly needed feature. It is blocker for us for using |
@seanmonstar are there any plans for this to be merged, or do you require any changes to be made? Getting this merged unblocks a PR in tungstenite that provides permessage-deflate support for websockets. |
@seanmonstar What would it take to get this merged? I'm willing to sponsor this work |
I know there's a lot of interest here. I've describe this a few times in chat, but never here. So, let me try:
|
I'm working on seanmonstar/warp#770 and noticed this is missing.