Join GitHub today
GitHub is home to over 50 million developers working together to host and review code, manage projects, and build software together.
Sign upImplement websocket subprotocol negotiation #8177
Comments
|
Thanks for creating this issue! I hope to make a PR tomorrow :) |
|
@jdm unfortunately I got stuck after only writing two lines of code. I added protocols: Vec<DOMString>,here: struct ConnectionEstablishedTask {
addr: Trusted<WebSocket>,
sender: Arc<Mutex<Sender<WebSocketStream>>>,
protocols: Vec<DOMString>,
}And then add protocols as an argument: let open_task = box ConnectionEstablishedTask {
addr: address.clone(),
sender: ws_sender.clone(),
protocols: protocols.iter().cloned().collect(),
};When I do this I get an error: 211:48 error: `protocols` does not live long enoughI tried a bunch of things to convert the Slice of DOMStrings to a Vec (the version above just being the most recent) and it appears the compiler thinks the protocols provided in the construtor (below) are not living long enough to be passed as an argument. pub fn Constructor(global: GlobalRef,
url: DOMString,
protocols: Option<DOMString>)
-> Fallible<Root<WebSocket>> {Any suggestions? |
|
ps. All of this is in the components/script/dom/websocket.rs file! |
|
Ah, I see the issue. We need to create the |
|
I think so, yes! Thank you! |
|
@jmr0 is going to work on this. |
|
Hey @jdm, I'm going over this now and wanted to make sure I captured the flow right:
Thanks! |
|
Yes, that looks correct to me! |
|
I ended up breaking the Protocol arrays are currently passed as a comma-separated string, so it wasn't immediately obvious how one would differentiate between a proper comma-separated list of protocols or some bogus protocol that happened to have a comma as part of its name. Let me know if you have any thoughts on this (hopefully that all makes sense). And feel free to take a look: jmr0@271df3f Thanks again :) |
adding initial support for websocket subprotocol negotation Addresses #8177 I also noticed some bugs/gaps (and at least one of my TODO's can be an E-Easy) cc @jdm <!-- Reviewable:start --> [<img src="https://reviewable.io/review_button.png" height=40 alt="Review on Reviewable"/>](https://reviewable.io/reviews/servo/servo/8825) <!-- Reviewable:end -->
adding initial support for websocket subprotocol negotation Addresses #8177 I also noticed some bugs/gaps (and at least one of my TODO's can be an E-Easy) cc @jdm <!-- Reviewable:start --> [<img src="https://reviewable.io/review_button.png" height=40 alt="Review on Reviewable"/>](https://reviewable.io/reviews/servo/servo/8825) <!-- Reviewable:end -->
adding initial support for websocket subprotocol negotation Addresses #8177 I also noticed some bugs/gaps (and at least one of my TODO's can be an E-Easy) cc @jdm <!-- Reviewable:start --> [<img src="https://reviewable.io/review_button.png" height=40 alt="Review on Reviewable"/>](https://reviewable.io/reviews/servo/servo/8825) <!-- Reviewable:end -->
|
#544 has been solved |
|
#8825 merged, so we can open more specific issues for remaining pieces of this. |
Spec: https://html.spec.whatwg.org/multipage/comms.html#the-websocket-interface:dom-websocket-protocol and https://tools.ietf.org/html/rfc6455#section-1.9
Tests:
./mach test-wpt tests/wpt/web-platform-tests/websockets/There are a bunch of tests that fail because the
websocket.protocolattribute is missing fromWebSocket.webidl. There are also a number of tests that fail because they rely on subprotocols, which we don't support. We should implement the missing piece from the "When the WebSocket connection is established" (seeConnectionEstablishedTask::handler). Additionally, we should set the appropriate header on the request object (seeestablish_a_websocket_connectionand the appropriate header).Code:
components/script/dom/websocket.rsNote: this issue is already assigned to someone, so please talk with me before starting work on it :)