Skip to content

Commit

Permalink
Support websocket subprotocl. (#1092)
Browse files Browse the repository at this point in the history
* Support websocket subprotocl.

* use HTTPHeader()
  • Loading branch information
LokiWager committed Sep 27, 2023
1 parent 0722e3b commit 9ad9310
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions pkg/filters/proxies/httpproxy/wspool.go
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,10 @@ func (sp *WebSocketServerPool) handle(ctx *context.Context) (result string) {
InsecureSkipVerify: sp.spec.InsecureSkipVerify,
OriginPatterns: sp.spec.OriginPatterns,
}
subProtocol := req.HTTPHeader().Get("Sec-WebSocket-Protocol")
if subProtocol != "" {
opts.Subprotocols = []string{subProtocol}
}
clntConn, err := websocket.Accept(stdw, req.Std(), opts)
if err != nil {
logger.Errorf("%s: failed to establish client connection: %v", sp.Name, err)
Expand Down

0 comments on commit 9ad9310

Please sign in to comment.