Skip to content

Commit

Permalink
Merge branch 'main' into main
Browse files Browse the repository at this point in the history
  • Loading branch information
gaby authored Aug 26, 2024
2 parents dee94a9 + 18e5577 commit ee9911b
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion websocket/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -142,4 +142,12 @@ cfg := Config{
app.Get("/ws/:id", websocket.New(func(c *websocket.Conn) {}, cfg))


```
```
## Note for WebSocket subprotocols
The config `Subprotocols` only helps you negotiate subprotocols and sets a `Sec-Websocket-Protocol` header if it has a suitable subprotocol. For more about negotiates process, check the comment for `Subprotocols` in [fasthttp.Upgrader](https://pkg.go.dev/github.com/fasthttp/websocket#Upgrader) .
All connections will be sent to the handler function no matter whether the subprotocol negotiation is successful or not. You can get the selected subprotocol from `conn.Subprotocol()`.
If a connection includes the `Sec-Websocket-Protocol` header in the request but the protocol negotiation fails, the browser will immediately disconnect the connection after receiving the upgrade response.

0 comments on commit ee9911b

Please sign in to comment.