Get the value once for IsWebSocketRequest property
This commit is contained in:
parent
94bb58f4fc
commit
fa01992fa1
@ -39,6 +39,8 @@ namespace WebSocketSharp
|
|||||||
|
|
||||||
private string _method;
|
private string _method;
|
||||||
private string _uri;
|
private string _uri;
|
||||||
|
private bool _websocketRequest;
|
||||||
|
private bool _websocketRequestWasSet;
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
@ -94,11 +96,17 @@ namespace WebSocketSharp
|
|||||||
|
|
||||||
public bool IsWebSocketRequest {
|
public bool IsWebSocketRequest {
|
||||||
get {
|
get {
|
||||||
var headers = Headers;
|
if (!_websocketRequestWasSet) {
|
||||||
return _method == "GET" &&
|
var headers = Headers;
|
||||||
ProtocolVersion > HttpVersion.Version10 &&
|
_websocketRequest = _method == "GET" &&
|
||||||
headers.Contains ("Upgrade", "websocket") &&
|
ProtocolVersion > HttpVersion.Version10 &&
|
||||||
headers.Contains ("Connection", "Upgrade");
|
headers.Contains ("Upgrade", "websocket") &&
|
||||||
|
headers.Contains ("Connection", "Upgrade");
|
||||||
|
|
||||||
|
_websocketRequestWasSet = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return _websocketRequest;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -83,6 +83,8 @@ namespace WebSocketSharp.Net
|
|||||||
private Uri _url;
|
private Uri _url;
|
||||||
private string [] _userLanguages;
|
private string [] _userLanguages;
|
||||||
private Version _version;
|
private Version _version;
|
||||||
|
private bool _websocketRequest;
|
||||||
|
private bool _websocketRequestWasSet;
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
@ -273,10 +275,16 @@ namespace WebSocketSharp.Net
|
|||||||
/// </value>
|
/// </value>
|
||||||
public bool IsWebSocketRequest {
|
public bool IsWebSocketRequest {
|
||||||
get {
|
get {
|
||||||
return _method == "GET" &&
|
if (!_websocketRequestWasSet) {
|
||||||
_version > HttpVersion.Version10 &&
|
_websocketRequest = _method == "GET" &&
|
||||||
_headers.Contains ("Upgrade", "websocket") &&
|
_version > HttpVersion.Version10 &&
|
||||||
_headers.Contains ("Connection", "Upgrade");
|
_headers.Contains ("Upgrade", "websocket") &&
|
||||||
|
_headers.Contains ("Connection", "Upgrade");
|
||||||
|
|
||||||
|
_websocketRequestWasSet = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return _websocketRequest;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user