Fix for request url

This commit is contained in:
sta
2014-05-28 14:20:46 +09:00
parent 9909c52d2d
commit 331d840775
8 changed files with 143 additions and 155 deletions

View File

@@ -505,10 +505,8 @@ namespace WebSocketSharp.Server
private void acceptWebSocketRequest (HttpListenerWebSocketContext context)
{
var path = context.Path;
WebSocketServiceHost host;
if (path == null || !_services.TryGetServiceHostInternally (path, out host)) {
if (!_services.TryGetServiceHostInternally (context.RequestUri.AbsolutePath, out host)) {
context.Close (HttpStatusCode.NotImplemented);
return;
}

View File

@@ -492,16 +492,28 @@ namespace WebSocketSharp.Server
private void acceptWebSocket (TcpListenerWebSocketContext context)
{
var path = context.Path;
WebSocketServiceHost host;
if (path == null || !_services.TryGetServiceHostInternally (path, out host)) {
context.Close (HttpStatusCode.NotImplemented);
var reqUri = context.RequestUri;
if (reqUri == null) {
context.Close (HttpStatusCode.BadRequest);
return;
}
if (_uri.IsAbsoluteUri)
context.WebSocket.Url = new Uri (_uri, path);
if (_uri.IsAbsoluteUri) {
var req = reqUri.DnsSafeHost;
var expected = _uri.DnsSafeHost;
if (Uri.CheckHostName (req) == UriHostNameType.Dns &&
Uri.CheckHostName (expected) == UriHostNameType.Dns &&
req != expected) {
context.Close (HttpStatusCode.NotFound);
return;
}
}
WebSocketServiceHost host;
if (!_services.TryGetServiceHostInternally (reqUri.AbsolutePath, out host)) {
context.Close (HttpStatusCode.NotImplemented);
return;
}
host.StartSession (context);
}