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