File tree Expand file tree Collapse file tree 1 file changed +12
-11
lines changed Expand file tree Collapse file tree 1 file changed +12
-11
lines changed Original file line number Diff line number Diff line change @@ -752,19 +752,20 @@ function websocket_methods:accept(options, timeout)
752752 response_headers :upsert (" sec-websocket-accept" , base64_sha1 (self .key .. magic ))
753753
754754 local chosen_protocol
755- if self .protocols then
756- if options .protocols then
757- for _ , protocol in ipairs (options .protocols ) do
758- if self .protocols [protocol ] then
759- chosen_protocol = protocol
760- break
761- end
755+ if self .protocols and options .protocols then
756+ --[[ The |Sec-WebSocket-Protocol| request-header field can be
757+ used to indicate what subprotocols (application-level protocols
758+ layered over the WebSocket Protocol) are acceptable to the client.
759+ The server selects one or none of the acceptable protocols and echoes
760+ that value in its handshake to indicate that it has selected that
761+ protocol.]]
762+ for _ , protocol in ipairs (options .protocols ) do
763+ if self .protocols [protocol ] then
764+ response_headers :upsert (" sec-websocket-protocol" , protocol )
765+ chosen_protocol = protocol
766+ break
762767 end
763768 end
764- if not chosen_protocol then
765- return nil , " no matching protocol" , ce .EILSEQNOSUPPORT
766- end
767- response_headers :upsert (" sec-websocket-protocol" , chosen_protocol )
768769 end
769770
770771 do
You can’t perform that action at this time.
0 commit comments