Modified validating the connection request and response
This commit is contained in:
parent
ab2ef30f02
commit
93b30f94d7
@ -81,8 +81,7 @@ namespace WebSocketSharp
|
||||
return ProtocolVersion >= HttpVersion.Version11 &&
|
||||
StatusCode == "101" &&
|
||||
Headers.Contains ("Upgrade", "websocket") &&
|
||||
Headers.Contains ("Connection", "Upgrade") &&
|
||||
!Headers ["Sec-WebSocket-Accept"].IsNullOrEmpty ();
|
||||
Headers.Contains ("Connection", "Upgrade");
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1260,19 +1260,20 @@ namespace WebSocketSharp
|
||||
// As server
|
||||
private bool validateConnectionRequest (WebSocketContext context)
|
||||
{
|
||||
string version;
|
||||
return context.IsWebSocketRequest &&
|
||||
validateHostHeader (context.Host) &&
|
||||
!context.SecWebSocketKey.IsNullOrEmpty () &&
|
||||
context.Headers.Contains ("Sec-WebSocket-Version", _version);
|
||||
((version = context.SecWebSocketVersion) != null && version == _version);
|
||||
}
|
||||
|
||||
// As client
|
||||
private bool validateConnectionResponse (HandshakeResponse response)
|
||||
{
|
||||
string accept, version;
|
||||
return response.IsWebSocketResponse &&
|
||||
response.Headers.Contains ("Sec-WebSocket-Accept", createResponseKey ()) &&
|
||||
(!response.Headers.Contains ("Sec-WebSocket-Version") ||
|
||||
response.Headers.Contains ("Sec-WebSocket-Version", _version));
|
||||
((accept = response.Headers ["Sec-WebSocket-Accept"]) != null && accept == createResponseKey ()) &&
|
||||
((version = response.Headers ["Sec-WebSocket-Version"]) == null || version == _version);
|
||||
}
|
||||
|
||||
// As server
|
||||
|
Loading…
Reference in New Issue
Block a user