Example #1
0
        public void HostHttp(
            [Argument("port", DefaultValue = 8080, Description = "The port number to listen on.")] int port,
            [Argument("root", DefaultValue = "", Description = "Requests constrained within the URI folder.")] string rootFolder,
            [Argument("remote", DefaultValue = false, Description = "Allow requests from other machines.")] bool allowRemote,
            [Argument("browse", DefaultValue = false, Description = "Allow requests from other machines.")] bool startBrowser)
        {
            string[] prefixes = GetHttpPrefixes(allowRemote, port, rootFolder);
            using (HttpServer server = new CSharpTest.Net.Http.HttpServer(5))
            {
                server.ProcessRequest += ServerOnProcessRequest;
                server.Start(prefixes);

                Console.WriteLine("Listening on {0}", prefixes[0]);
                if (startBrowser)
                {
                    System.Diagnostics.Process.Start(prefixes[0]);
                }
                Console.WriteLine("Press [Enter] to quit");
                Console.ReadLine();

                server.Stop();
            }
        }
Example #2
0
 internal HttpContextEventArgs(HttpServer host, HttpListenerContext context)
 {
     Host = host;
     Context = context;
 }