Added the WebSocketBehavior.IgnoreExtensions property, to ignore the extensions requested from the client
This commit is contained in:
parent
dac4a4a489
commit
f5a1ce2c53
@ -47,6 +47,7 @@ namespace WebSocketSharp.Server
|
|||||||
private WebSocketContext _context;
|
private WebSocketContext _context;
|
||||||
private Func<CookieCollection, CookieCollection, bool> _cookiesValidator;
|
private Func<CookieCollection, CookieCollection, bool> _cookiesValidator;
|
||||||
private string _id;
|
private string _id;
|
||||||
|
private bool _ignoreExtensions;
|
||||||
private Func<string, bool> _originValidator;
|
private Func<string, bool> _originValidator;
|
||||||
private string _protocol;
|
private string _protocol;
|
||||||
private WebSocketSessionManager _sessions;
|
private WebSocketSessionManager _sessions;
|
||||||
@ -159,6 +160,24 @@ namespace WebSocketSharp.Server
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets or sets a value indicating whether the WebSocket service ignores
|
||||||
|
/// the Sec-WebSocket-Extensions header included in a connection request.
|
||||||
|
/// </summary>
|
||||||
|
/// <value>
|
||||||
|
/// <c>true</c> if the WebSocket service ignores the extensions; otherwise, <c>false</c>.
|
||||||
|
/// The default value is <c>false</c>.
|
||||||
|
/// </value>
|
||||||
|
public bool IgnoreExtensions {
|
||||||
|
get {
|
||||||
|
return _ignoreExtensions;
|
||||||
|
}
|
||||||
|
|
||||||
|
set {
|
||||||
|
_ignoreExtensions = value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets or sets the delegate called to validate the Origin header included in a connection
|
/// Gets or sets the delegate called to validate the Origin header included in a connection
|
||||||
/// request to the WebSocket service.
|
/// request to the WebSocket service.
|
||||||
@ -316,6 +335,7 @@ namespace WebSocketSharp.Server
|
|||||||
|
|
||||||
_websocket = context.WebSocket;
|
_websocket = context.WebSocket;
|
||||||
_websocket.CustomHandshakeRequestChecker = checkIfValidConnectionRequest;
|
_websocket.CustomHandshakeRequestChecker = checkIfValidConnectionRequest;
|
||||||
|
_websocket.IgnoreExtensions = _ignoreExtensions;
|
||||||
_websocket.Protocol = _protocol;
|
_websocket.Protocol = _protocol;
|
||||||
|
|
||||||
var waitTime = sessions.WaitTime;
|
var waitTime = sessions.WaitTime;
|
||||||
|
@ -86,6 +86,7 @@ namespace WebSocketSharp
|
|||||||
private const string _guid = "258EAFA5-E914-47DA-95CA-C5AB0DC85B11";
|
private const string _guid = "258EAFA5-E914-47DA-95CA-C5AB0DC85B11";
|
||||||
private Func<WebSocketContext, string>
|
private Func<WebSocketContext, string>
|
||||||
_handshakeRequestChecker;
|
_handshakeRequestChecker;
|
||||||
|
private bool _ignoreExtensions;
|
||||||
private volatile Logger _logger;
|
private volatile Logger _logger;
|
||||||
private Queue<MessageEventArgs> _messageEventQueue;
|
private Queue<MessageEventArgs> _messageEventQueue;
|
||||||
private uint _nonceCount;
|
private uint _nonceCount;
|
||||||
@ -225,6 +226,17 @@ namespace WebSocketSharp
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// As server
|
||||||
|
internal bool IgnoreExtensions {
|
||||||
|
get {
|
||||||
|
return _ignoreExtensions;
|
||||||
|
}
|
||||||
|
|
||||||
|
set {
|
||||||
|
_ignoreExtensions = value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
internal bool IsConnected {
|
internal bool IsConnected {
|
||||||
get {
|
get {
|
||||||
return _readyState == WebSocketState.Open || _readyState == WebSocketState.Closing;
|
return _readyState == WebSocketState.Open || _readyState == WebSocketState.Closing;
|
||||||
@ -577,9 +589,11 @@ namespace WebSocketSharp
|
|||||||
!_context.SecWebSocketProtocols.Contains (protocol => protocol == _protocol))
|
!_context.SecWebSocketProtocols.Contains (protocol => protocol == _protocol))
|
||||||
_protocol = null;
|
_protocol = null;
|
||||||
|
|
||||||
|
if (!_ignoreExtensions) {
|
||||||
var extensions = _context.Headers["Sec-WebSocket-Extensions"];
|
var extensions = _context.Headers["Sec-WebSocket-Extensions"];
|
||||||
if (extensions != null && extensions.Length > 0)
|
if (extensions != null && extensions.Length > 0)
|
||||||
processSecWebSocketExtensionsHeader (extensions);
|
processSecWebSocketExtensionsHeader (extensions);
|
||||||
|
}
|
||||||
|
|
||||||
return sendHttpResponse (createHandshakeResponse ());
|
return sendHttpResponse (createHandshakeResponse ());
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user