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

Support websocket subprotocl. #1092

Merged
merged 2 commits into from
Sep 27, 2023
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Support websocket subprotocl.
  • Loading branch information
LokiWager committed Sep 26, 2023
commit ee4d16e971a2341f844c6af6707c09936b9ee22e
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.Header().Get("Sec-WebSocket-Protocol")
if subProtocol != "" {
opts.Subprotocols = []string{subProtocol.(string)}
}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
subProtocol := req.Header().Get("Sec-WebSocket-Protocol")
if subProtocol != "" {
opts.Subprotocols = []string{subProtocol.(string)}
}
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
Loading