Fixed HttpServer.cs

This commit is contained in:
sta
2012-09-13 11:18:52 +09:00
parent ce93711cf2
commit 9730e2a9ff
20 changed files with 22 additions and 11 deletions
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
+22 -11
View File
@@ -40,6 +40,7 @@ namespace WebSocketSharp.Server {
#region Fields
private Thread _acceptRequestThread;
private bool _isWindows;
private HttpListener _listener;
private int _port;
private string _rootPath;
@@ -62,14 +63,9 @@ namespace WebSocketSharp.Server {
public HttpServer(int port, string wsPath)
{
_listener = new HttpListener();
_port = port;
var prefix = String.Format(
"http{0}://*:{1}/", _port == 443 ? "s" : String.Empty, _port);
_listener.Prefixes.Add(prefix);
_wsPath = wsPath.ToUri();
_wsServer = new WebSocketServer<T>();
configureFromConfigFile();
_port = port;
_wsPath = wsPath.ToUri();
init();
}
#endregion
@@ -126,6 +122,23 @@ namespace WebSocketSharp.Server {
_rootPath = ConfigurationManager.AppSettings["RootPath"];
}
private void init()
{
_isWindows = false;
_listener = new HttpListener();
_wsServer = new WebSocketServer<T>();
var os = Environment.OSVersion;
if (os.Platform != PlatformID.Unix && os.Platform != PlatformID.MacOSX)
_isWindows = true;
var prefix = String.Format(
"http{0}://*:{1}/", _port == 443 ? "s" : String.Empty, _port);
_listener.Prefixes.Add(prefix);
configureFromConfigFile();
}
private bool isUpgrade(HttpListenerRequest request, string value)
{
if (!request.Headers.Exists("Upgrade", value))
@@ -257,9 +270,7 @@ namespace WebSocketSharp.Server {
public byte[] GetFile(string path)
{
var filePath = _rootPath + path;
var os = Environment.OSVersion;
if (os.Platform != PlatformID.Unix && os.Platform != PlatformID.MacOSX)
if (_isWindows)
filePath = filePath.Replace("/", "\\");
if (File.Exists(filePath))
Binary file not shown.
Binary file not shown.