Пример #1
0
        static void Main(string[] args)
        {
            /*
             * byte[] b = new byte[]{ 0, 1, 2, 3, 4, 5 };
             * NoSeekMemoryStream n = new NoSeekMemoryStream(b);
             *
             * // n.Seek(1,System.IO.SeekOrigin.Begin);
             * byte[] b2 = new byte[1000];
             * n.Read(b2, 0, 1000);
             * foreach(var i in b2) { Console.Out.Write(i); }
             *
             * UnitTests u = new UnitTests();
             * u.runTests();
             */
            StandardFileSystem fs = StandardFileSystem.Create("C:\\Users\\lt_va\\Documents");

            //StandardFileSystem fs = StandardFileSystem.Create("C:\\Users\\lt_va\\Documents");
            WebServer.AddService(new FilesWebService(fs));
            WebServer.Start(9000, 10);
            //Thread.Sleep(10);
            //WebServer.Stop();

            //TestBigNum test = new TestBigNum();

            //ConcatStreamUnitTests.Test();
            //NoSeekMemoryStreamTests.Test();
        }
Пример #2
0
        static void Main()
        {
            //var blah = string.Format(DefaultTemplate, 11216720, DateTime.Now, "blah");
            //Console.WriteLine(blah);

            WebServer.Start(4220, DefaultTemplate);

            /*System.Net.Sockets.TcpListener listener = new System.Net.Sockets.TcpListener(System.Net.IPAddress.Any, 4220);
             * listener.Start();
             * System.Net.Sockets.TcpClient client = listener.AcceptTcpClient();
             * var buf = System.Text.Encoding.ASCII.GetBytes(blah);
             *
             * int i_read, totalRead = 0;
             *
             * // Loop to receive all the data sent by the client.
             * i_read = client.GetStream().Read(buf, 0, buf.Length);
             *
             * while (i_read != 0)
             * {
             *  totalRead += i_read;
             *  i_read = client.GetStream().Read(buf, totalRead, buf.Length - totalRead);
             * }
             *
             * //client.GetStream().Read(buf, 0, buf.Length);
             * //buf = System.Text.Encoding.ASCII.GetBytes(blah);
             * client.GetStream().Write(buf, 0, buf.Length);
             * client.Close();*/
        }
Пример #3
0
        public static void Main(string[] args)
        {
            var responseTemplate = string.Format(DefaultTemplate, 11343200, DateTime.Now.Ticks, "HelloWorld!");

            Console.WriteLine("Starting server on port 4220");

            WebServer.Start(4220, responseTemplate);
        }
Пример #4
0
        public static void Main(string[] args)
        {
            StandardFileSystem sfs = StandardFileSystem.Create("/Users");

            WebServer.AddService(new FileWebService(sfs));
            WebServer.Start(13000, 32);
            WebServer.Stop();
        }
Пример #5
0
        public static void Main()
        {
            StandardFileSystem a = StandardFileSystem.Create("/home/devjeetroy/");

            //Console.WriteLine (a.GetRoot ().GetFiles ()[0].Name);
            WebServer.AddService(new FilesWebService(a));
            WebServer.Start(8080, 64);
        }
Пример #6
0
        public static void Main()
        {
            WebServer.AddService(new DemoService());
            WebServer.Start(8080, 64);

            Thread newThread = new Thread(stopServer);

            newThread.Start();
        }
Пример #7
0
        public static void Main(string[] args)
        {
            WebServer.AddService(new FilesWebService(StandardFileSystem.Create("/")));

            Console.WriteLine("Starting server on port {0}", PORT);

            WebServer.Start(PORT, 10);

            Console.ReadKey();
        }
Пример #8
0
        static void master()
        {
            const string DefaultTemplate = "HTTP/1.1 200 OK\r\n" +
                                           "Content-Type:text/html\r\n" +
                                           "\r\n\r\n" +
                                           "<html>ID Number: {0}<br>" +
                                           "DateTime.Now: {1}<br>" +
                                           "Requested URL: {2}</html>";

            WebServer.Start(1337, 64);
        }
Пример #9
0
        public static void Main(string[] args)
        {
            WebServer.Start(4220, 1);
            FilesWebService fileService = new FilesWebService(StandardFileSystem.Create("/home/jakeknott/Desktop"));

            WebServer.AddService(fileService);

            while (true)
            {
            }
        }
Пример #10
0
        static void master()
        {
            const string DefaultTemplate = "HTTP/1.1 200 OK\r\n" +
                                           "Content-Type:text/html\r\n" +
                                           "\r\n\r\n" +
                                           "<html>ID Number: {0}</br>" +
                                           "DateTime.Now: {1}</br>" +
                                           "Requested URL: {2}</html>";

            WebServer.Start(1337, 64);

            WebService service = new FilesWebService(StandardFileSystem.Create("/Users/ellio/desktop"));

            WebServer.AddService(service);
        }
Пример #11
0
        public void TestCase()
        {
            WebServer server = new WebServer();

            WebServer.Start(4422, 0);
            WebService service = new DemoService();

            server.AddService(service);

            while (true)
            {
            }


            WebServer.Stop();
        }
Пример #12
0
        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();
        }
Пример #13
0
        public static void Main(string[] args)
        {
            if (args.Length == 0)
            {
                Console.WriteLine(WebServer.Start(port, response));
            }
            else if (args[0] == "1")
            {
                WebServer.Start(port, response);
            }

            else
            {
                Client.Connect("127.0.0.1", port,
                               "GET /oogabooga HTTP/1.1\r\n \r\n\r\n"
                               );
            }
        }
Пример #14
0
        static void Main()
        {
            //Mac
            //WebServer.AddService(new FilesWebService(StandardFileSystem.Create("/Users/Gene/Desktop")));

            //Linux
            WebServer.AddService(new FilesWebService(StandardFileSystem.Create("/home/gene/Desktop")));

            /*var mfs = new MemoryFileSystem();
             * var root = mfs.GetRoot();
             * root.CreateDir("FooDir");
             * root.CreateFile("barFile");
             * var barFile = root.GetFile("barFile");
             * var barFileStream = barFile.OpenReadWrite();
             * barFileStream.Write(Encoding.ASCII.GetBytes("Hello World"), 0, Encoding.ASCII.GetBytes("Hello World").Length);
             * barFileStream.Close();
             * WebServer.AddService(new FilesWebService(mfs));*/

            WebServer.Start(8080, 64);
        }
Пример #15
0
        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);*/
        }
Пример #16
0
 public static void Main(string[] args)
 {
     WebServer.AddService(new DemoService());
     WebServer.Start(13000, 32);
     WebServer.Stop();
 }
Пример #17
0
 public void Init()
 {
     WebServer.AddService(new DemoService());
     WebServer.Start(PORT, 10);
 }
Пример #18
0
 static void Main()
 {
     WebServer.AddService(new DemoService());
     WebServer.Start(8080, 64);
 }