diff --git a/websocket-sharp/Net/HttpConnection.cs b/websocket-sharp/Net/HttpConnection.cs index 08ea56b7..5be058dd 100644 --- a/websocket-sharp/Net/HttpConnection.cs +++ b/websocket-sharp/Net/HttpConnection.cs @@ -302,9 +302,8 @@ namespace WebSocketSharp.Net conn._lastListener = lsnr; } - conn._contextBound = true; - if (!lsnr.RegisterContext (conn._context)) - conn._contextBound = false; + if (lsnr.RegisterContext (conn._context)) + conn._contextBound = true; return; } diff --git a/websocket-sharp/Net/HttpListener.cs b/websocket-sharp/Net/HttpListener.cs index 1973ad97..cdcb476c 100644 --- a/websocket-sharp/Net/HttpListener.cs +++ b/websocket-sharp/Net/HttpListener.cs @@ -587,6 +587,9 @@ namespace WebSocketSharp.Net if (!_listening) return false; + if (!Authenticate (context)) + return false; + lock (_ctxRegistrySync) { if (!_listening) return false; diff --git a/websocket-sharp/Net/HttpListenerAsyncResult.cs b/websocket-sharp/Net/HttpListenerAsyncResult.cs index 37cdf0b4..a1c73742 100644 --- a/websocket-sharp/Net/HttpListenerAsyncResult.cs +++ b/websocket-sharp/Net/HttpListenerAsyncResult.cs @@ -179,18 +179,6 @@ namespace WebSocketSharp.Net internal void Complete (HttpListenerContext context, bool syncCompleted) { - try { - var lsnr = context.Listener; - if (!lsnr.Authenticate (context)) { - lsnr.BeginGetContext (this); - return; - } - } - catch (Exception ex) { - Complete (ex); - return; - } - _context = context; _syncCompleted = syncCompleted;