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

Improve upgrader documentation regarding protocols #404

Open
garyburd opened this issue Jul 31, 2018 · 4 comments
Open

Improve upgrader documentation regarding protocols #404

garyburd opened this issue Jul 31, 2018 · 4 comments

Comments

@garyburd
Copy link
Contributor

garyburd commented Jul 31, 2018

Points to cover

  • An application can handle subprotocol negotiation on its own by setting the Sec-Websocket-Protocol response header. The Subprotocols(r *http.Request) []string function is helpful here.
  • Set u.Subprotocols for builtin subprotocol negotiation. Builtin negotiation overrides a subprotocol specified in the response header (it would have been better to return an error, but it's too late to change that).
  • Builtin negotiation uses first match in u.Subprotocols. If there's no match, then no protocol is negotiated.
@marti1125
Copy link

Hi! Could I contribute with it =?

@IngCr3at1on
Copy link

Hi, @marti1125 yes absolutely! Documentation contributions are always welcome assuming they're clear and concise; my vote, feel free to open a pull request if you have documentation you believe would be useful.

@marti1125
Copy link

I am trying to understand subprotocols using client/server example

I just modify https://github.com/gorilla/websocket/blob/master/examples/echo/server.go#L23

c, err := upgrader.Upgrade(w, r, r.Header)

in the terminal show upgrade:websocket: application specific 'Sec-WebSocket-Extensions' headers are unsupported

@ghost
Copy link

ghost commented Oct 2, 2019

@marti1125 It looks like you added a Sec-WebSocket-Extensions header, but that header is unrelated to subprotocols. Did you you intend to add a Sec-Websocket-Protocol instead?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: No status
Development

No branches or pull requests

5 participants