From 7147cde22c1ee87c7337033ac4d8ebac556c650b Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 7 Jan 2014 14:19:58 +0900 Subject: [PATCH] Fix for internal uri of WebSocket class as a server --- websocket-sharp/Server/WebSocketServer.cs | 3 +++ websocket-sharp/WebSocket.cs | 15 ++++++++------- 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/websocket-sharp/Server/WebSocketServer.cs b/websocket-sharp/Server/WebSocketServer.cs index 6d19a2ff..8e37d360 100644 --- a/websocket-sharp/Server/WebSocketServer.cs +++ b/websocket-sharp/Server/WebSocketServer.cs @@ -485,6 +485,9 @@ namespace WebSocketSharp.Server return; } + if (_uri.IsAbsoluteUri) + context.WebSocket.Url = new Uri (_uri, path); + host.StartSession (context); } diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index 8648bb6c..430b9cf4 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -117,7 +117,7 @@ namespace WebSocketSharp _closeContext = context.Close; _secure = context.IsSecureConnection; _stream = context.Stream; - _uri = context.RequestUri; + _uri = context.Path.ToUri (); init (); } @@ -131,7 +131,7 @@ namespace WebSocketSharp _closeContext = context.Close; _secure = context.IsSecureConnection; _stream = context.Stream; - _uri = context.RequestUri; + _uri = context.Path.ToUri (); init (); } @@ -1317,7 +1317,8 @@ namespace WebSocketSharp } // As server - private bool validateCookies (CookieCollection request, CookieCollection response) + private bool validateCookies ( + CookieCollection request, CookieCollection response) { return _cookiesValidation != null ? _cookiesValidation (request, response) @@ -1335,11 +1336,11 @@ namespace WebSocketSharp var i = value.IndexOf (':'); var host = i > 0 ? value.Substring (0, i) : value; - var type = Uri.CheckHostName (host); + var expected = _uri.DnsSafeHost; - return type != UriHostNameType.Dns || - Uri.CheckHostName (_uri.DnsSafeHost) != UriHostNameType.Dns || - host == _uri.DnsSafeHost; + return Uri.CheckHostName (host) != UriHostNameType.Dns || + Uri.CheckHostName (expected) != UriHostNameType.Dns || + host == expected; } #endregion