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 #13

Open
tebruno99 opened this issue Dec 13, 2022 · 5 comments
Open

Improve upgrader documentation regarding protocols #13

tebruno99 opened this issue Dec 13, 2022 · 5 comments
Labels
documentation Improvements or additions to documentation waiting on new maintainer

Comments

@tebruno99
Copy link

From websocket created by garyburd: gorilla#404

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.
@tebruno99 tebruno99 added documentation Improvements or additions to documentation waiting on new maintainer labels Dec 13, 2022
@tebruno99
Copy link
Author

tebruno99 commented Dec 13, 2022

Originial Comment: @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?

@tebruno99
Copy link
Author

tebruno99 commented Dec 13, 2022

Originial Comment: @IngCr3at1on

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.

@tebruno99

This comment was marked as outdated.

@tebruno99
Copy link
Author

tebruno99 commented Dec 13, 2022

Originial Comment: @marti1125

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

@tebruno99
Copy link
Author

Orginal Comment: @ghost

@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
Labels
documentation Improvements or additions to documentation waiting on new maintainer
Projects
None yet
Development

No branches or pull requests

1 participant