public static void Main(string[] args) { StandardFileSystem sfs = StandardFileSystem.Create("/Users"); WebServer.AddService(new FileWebService(sfs)); WebServer.Start(13000, 32); WebServer.Stop(); }
static void stopServer() { var start = DateTime.Now; var secondsElapsed = (DateTime.Now - start).TotalSeconds; while (((secondsElapsed = (DateTime.Now - start).TotalSeconds) <= 10)) { } Console.WriteLine("Stopping server"); WebServer.Stop(); Thread.CurrentThread.Abort(); }
public void TestCase() { WebServer server = new WebServer(); WebServer.Start(4422, 0); WebService service = new DemoService(); server.AddService(service); while (true) { } WebServer.Stop(); }
public void TestCase() { string requestLine = "GET "; for (int i = 0; i < 2048; i++) { requestLine += "a"; } requestLine += "HTTP/1.1\r\n\r\n"; byte[] byteArray = Encoding.UTF8.GetBytes(requestLine); //byte[] byteArray = Encoding.ASCII.GetBytes(contents); MemoryStream stream = new MemoryStream(byteArray); ValidateRequest validate = new ValidateRequest(); Assert.IsFalse(validate.IsValid(stream)); requestLine = "GET URL HTTP/1.1\r\n"; // this is valid for (int i = 0; i < 100 * 1024; i++) { requestLine += "a:"; //adding a lot of giberish for the 'headers' } byteArray = Encoding.UTF8.GetBytes(requestLine); stream = new MemoryStream(byteArray); validate = new ValidateRequest(); Assert.IsFalse(validate.IsValid(stream)); WebServer server = new WebServer(); WebServer.Start(4422, 0); WebService service = new DemoService(); server.AddService(service); while (true) { } WebServer.Stop(); }
public static void Main(string[] args) { WebServer.Start(3000, 10); //Add the DemoService to the list of available services WebServer.AddService(new DemoService()); WebServer.AddService(new FilesWebService(StandardFileSystem.Create("/Users"))); while (true) { string input = Console.ReadLine(); if (input == "Stop") { WebServer.Stop(); break; } } /*RequestValidator rv = new RequestValidator(); * string putr = "PUT /hello.htm HTTP/1.1\r\nUser-Agent: Mozilla/4.0 (compatible; MSIE5.01; Windows NT)\r\nHost: www.tutorialspoint.com\r\nAccept-Language: en-us\r\nConnection: Keep-Alive\r\nContent-type: text/html\r\nContent-Length: 182\r\n\r\n"; * rv.testValidator(putr);*/ }
public void Dispose() { WebServer.Stop(); }
public static void Main(string[] args) { WebServer.AddService(new DemoService()); WebServer.Start(13000, 32); WebServer.Stop(); }