File tree Expand file tree Collapse file tree 1 file changed +2
-1
lines changed
WebSockets/WebSocketServer Expand file tree Collapse file tree 1 file changed +2
-1
lines changed Original file line number Diff line number Diff line change @@ -150,6 +150,7 @@ public bool AddWebSocket(HttpListenerContext context)
150150 var headerConnection = context . Request . Headers [ "Connection" ] ;
151151 var headerUpgrade = context . Request . Headers [ "Upgrade" ] ;
152152 var headerSwk = context . Request . Headers [ "Sec-WebSocket-Key" ] ;
153+ var headerSecProtocol = context . Request . Headers [ "Sec-WebSocket-Protocol" ] ;
153154 WebSocketContext websocketContext = context . GetWebsocketContext ( ) ;
154155
155156 if ( headerConnection == "Upgrade" && headerUpgrade == "websocket" && ! string . IsNullOrEmpty ( headerSwk ) )
@@ -166,7 +167,7 @@ public bool AddWebSocket(HttpListenerContext context)
166167 string swka = swk + "258EAFA5-E914-47DA-95CA-C5AB0DC85B11" ; //default signature for websocket
167168 byte [ ] swkaSha1 = WebSocketHelpers . ComputeHash ( swka ) ;
168169 string swkaSha1Base64 = Convert . ToBase64String ( swkaSha1 ) ;
169- byte [ ] response = Encoding . UTF8 . GetBytes ( $ "HTTP/1.1 101 Web Socket Protocol Handshake\r \n Connection: Upgrade\r \n Sec-WebSocket-Accept: { swkaSha1Base64 } \r \n Server: { ServerName } \r \n Upgrade: websocket\r \n \r \n ") ;
170+ byte [ ] response = Encoding . UTF8 . GetBytes ( $ "HTTP/1.1 101 Web Socket Protocol Handshake\r \n Connection: Upgrade\r \n Sec-WebSocket-Accept: { swkaSha1Base64 } \r \n Server: { ServerName } \r \n Upgrade: websocket{ ( ! string . IsNullOrEmpty ( headerSecProtocol ) ? " \r \n Sec-WebSocket-Protocol: " + headerSecProtocol : "" ) } \r \n \r \n ") ;
170171 websocketContext . NetworkStream . Write ( response , 0 , response . Length ) ;
171172
172173 var webSocketClient = new WebSocketServerClient ( _options ) ;
You can’t perform that action at this time.
0 commit comments