public void Start() { MainConsole.Instance.InfoFormat( "[BASE HTTP SERVER]: Starting {0} server on port {1}", Secure ? "HTTPS" : "HTTP", Port); try { //m_httpListener = new HttpListener(); NotSocketErrors = 0; m_internalServer = new HttpListenerManager(m_threadCount, Secure); if (OnOverrideRequest != null) { m_internalServer.ProcessRequest += OnOverrideRequest; } else { m_internalServer.ProcessRequest += OnRequest; } m_internalServer.Start(m_port); // Long Poll Service Manager with 3 worker threads a 25 second timeout for no events m_PollServiceManager = new PollServiceRequestManager(this, 3, 25000); m_PollServiceManager.Start(); HTTPDRunning = true; } catch (Exception e) { if (e is HttpListenerException && ((HttpListenerException)e).Message == "Access is denied") { MainConsole.Instance.Error("[BASE HTTP SERVER]: You must run this program as an administrator."); } else { MainConsole.Instance.Error("[BASE HTTP SERVER]: Error - " + e.Message); MainConsole.Instance.Error("[BASE HTTP SERVER]: Tip: Do you have permission to listen on port " + m_port + "?"); } // We want this exception to halt the entire server since in current configurations we aren't too // useful without inbound HTTP. throw e; } }
public void Start() { MainConsole.Instance.InfoFormat( "[BASE HTTP SERVER]: Starting {0} server on port {1}", Secure ? "HTTPS" : "HTTP", Port); try { //m_httpListener = new HttpListener(); NotSocketErrors = 0; m_internalServer = new HttpListenerManager(m_threadCount, Secure); if (OnOverrideRequest != null) m_internalServer.ProcessRequest += OnOverrideRequest; else m_internalServer.ProcessRequest += OnRequest; m_internalServer.Start(m_port); // Long Poll Service Manager with 3 worker threads a 25 second timeout for no events m_PollServiceManager = new PollServiceRequestManager(3, 25000); m_PollServiceManager.Start(); HTTPDRunning = true; } catch (Exception e) { if (e is HttpListenerException && ((HttpListenerException) e).Message == "Access is denied") MainConsole.Instance.Error("[BASE HTTP SERVER]: You must run this program as an administrator."); else { MainConsole.Instance.Error("[BASE HTTP SERVER]: Error - " + e.Message); MainConsole.Instance.Error("[BASE HTTP SERVER]: Tip: Do you have permission to listen on port " + m_port + "?"); } // We want this exception to halt the entire server since in current configurations we aren't too // useful without inbound HTTP. throw e; } }
private void StartHTTP() { try { //m_httpListener = new HttpListener(); NotSocketErrors = 0; if (!m_isSecure) { //m_httpListener.Prefixes.Add("http://+:" + m_port + "/"); //m_httpListener.Prefixes.Add("http://10.1.1.5:" + m_port + "/"); m_httpListener = HttpListener.Create(m_listenIPAddress, (int)m_port/*, httpserverlog*/); m_httpListener.ExceptionThrown += httpServerException; m_httpListener.LogWriter = httpserverlog; // Uncomment this line in addition to those in HttpServerLogWriter // if you want more detailed trace information from the HttpServer //m_httpListener2.UseTraceLogs = true; //m_httpListener2.DisconnectHandler = httpServerDisconnectMonitor; } else { m_httpListener = HttpListener.Create(IPAddress.Any, (int)m_port, m_cert, m_sslProtocol); m_httpListener.ExceptionThrown += httpServerException; m_httpListener.LogWriter = httpserverlog; } m_httpListener.RequestReceived += OnRequest; m_httpListener.Start(64); // Long Poll Service Manager with 3 worker threads a 25 second timeout for no events m_PollServiceManager = new PollServiceRequestManager(this, 3, 25000); HTTPDRunning = true; } catch (Exception e) { MainConsole.Instance.Error("[BASE HTTP SERVER]: Error - " + e.Message); MainConsole.Instance.Error("[BASE HTTP SERVER]: Tip: Do you have permission to listen on port " + m_port + "?"); // We want this exception to halt the entire server since in current configurations we aren't too // useful without inbound HTTP. throw; } }
public void Start() { MainConsole.Instance.InfoFormat( "[BASE HTTP SERVER]: Starting {0} server on port {1}", Secure ? "HTTPS" : "HTTP", Port); try { //m_httpListener = new HttpListener(); NotSocketErrors = 0; if (!Secure) { //m_httpListener.Prefixes.Add("http://+:" + m_port + "/"); //m_httpListener.Prefixes.Add("http://10.1.1.5:" + m_port + "/"); m_httpListener2 = CoolHTTPListener.Create(m_listenIPAddress, (int)m_port); m_httpListener2.ExceptionThrown += httpServerException; m_httpListener2.LogWriter = httpserverlog; // Uncomment this line in addition to those in HttpServerLogWriter // if you want more detailed trace information from the HttpServer //m_httpListener2.UseTraceLogs = true; //m_httpListener2.DisconnectHandler = httpServerDisconnectMonitor; } else { //m_httpListener.Prefixes.Add("https://+:" + (m_sslport) + "/"); //m_httpListener.Prefixes.Add("http://+:" + m_port + "/"); m_httpListener2 = CoolHTTPListener.Create(IPAddress.Any, (int)m_port, m_cert); m_httpListener2.ExceptionThrown += httpServerException; m_httpListener2.LogWriter = httpserverlog; } m_httpListener2.RequestReceived += OnRequest; //m_httpListener.Start(); m_httpListener2.Start(64); // Long Poll Service Manager with 3 worker threads a 25 second timeout for no events m_PollServiceManager = new PollServiceRequestManager(this, 3, 25000); m_PollServiceManager.Start(); HTTPDRunning = true; //HttpListenerContext context; //while (true) //{ // context = m_httpListener.GetContext(); // ThreadPool.UnsafeQueueUserWorkItem(new WaitCallback(HandleRequest), context); // } } catch (Exception e) { MainConsole.Instance.Error("[BASE HTTP SERVER]: Error - " + e.Message); MainConsole.Instance.Error("[BASE HTTP SERVER]: Tip: Do you have permission to listen on port " + m_port + "?"); // We want this exception to halt the entire server since in current configurations we aren't too // useful without inbound HTTP. throw e; } }
public void Start() { try { var factory = new DelegatePipelineFactory(); factory.AddDownstreamHandler(() => new ResponseEncoder()); factory.AddUpstreamHandler(() => new HeaderDecoder(new HttpParser())); var decoder = new CompositeBodyDecoder(); decoder.Add("application/json", new JsonBodyDecoder()); decoder.Add("application/xml", new JsonBodyDecoder()); decoder.Add("application/x-gzip", new JsonBodyDecoder()); decoder.Add("application/llsd+json", new JsonBodyDecoder()); decoder.Add("application/llsd+xml", new JsonBodyDecoder()); decoder.Add("application/xml+llsd", new JsonBodyDecoder()); decoder.Add("application/octet-stream", new JsonBodyDecoder()); decoder.Add("text/html", new JsonBodyDecoder()); decoder.Add("text/xml", new JsonBodyDecoder()); decoder.Add("text/www-form-urlencoded", new JsonBodyDecoder()); decoder.Add("text/x-www-form-urlencoded", new JsonBodyDecoder()); factory.AddUpstreamHandler(() => new BodyDecoder(decoder, 65535, int.MaxValue)); factory.AddUpstreamHandler(() => (MessageHandler = new MessageHandler(this))); _httpListener = new HttpListener(factory); _httpListener.Start(new IPEndPoint(IPAddress.Any, (int)Port)); // Long Poll Service Manager with 3 worker threads a 25 second timeout for no events m_PollServiceManager = new PollServiceRequestManager(this, 3, 25000); HTTPDRunning = true; MainConsole.Instance.InfoFormat("[BASE HTTP SERVER]: Listening on port {0}", Port); } catch (Exception e) { MainConsole.Instance.Error("[BASE HTTP SERVER]: Error - " + e.Message); MainConsole.Instance.Error("[BASE HTTP SERVER]: Tip: Do you have permission to listen on port " + m_port + "?"); // We want this exception to halt the entire server since in current configurations we aren't too // useful without inbound HTTP. throw; } }