Fixed HttpServer.cs

This commit is contained in:
sta 2012-09-20 20:28:49 +09:00
parent 3898696491
commit 8868761635
20 changed files with 16 additions and 13 deletions

Binary file not shown.

View File

@ -153,18 +153,9 @@ namespace WebSocketSharp.Server {
try try
{ {
if (isUpgrade(req, "websocket")) if (isUpgrade(req, "websocket"))
{
if (req.IsWebSocketRequest)
{ {
if (upgradeToWebSocket(context)) if (upgradeToWebSocket(context))
return; return;
res.StatusCode = (int)HttpStatusCode.NotImplemented;
}
else
{
res.StatusCode = (int)HttpStatusCode.BadRequest;
}
} }
else else
{ {
@ -253,9 +244,21 @@ namespace WebSocketSharp.Server {
private bool upgradeToWebSocket(HttpListenerContext context) private bool upgradeToWebSocket(HttpListenerContext context)
{ {
var path = context.Request.RawUrl; var req = context.Request;
if (!_wsServers.ContainsKey(path)) var res = context.Response;
if (!req.IsWebSocketRequest)
{
res.StatusCode = (int)HttpStatusCode.BadRequest;
return false; return false;
}
var path = req.RawUrl;
if (!_wsServers.ContainsKey(path))
{
res.StatusCode = (int)HttpStatusCode.NotImplemented;
return false;
}
var wsContext = context.AcceptWebSocket(path); var wsContext = context.AcceptWebSocket(path);
var socket = wsContext.WebSocket; var socket = wsContext.WebSocket;

Binary file not shown.