예제 #1
0
        public override void HandlePostRequest(HttpProcessor p, StreamReader inputData)
        {
            Console.WriteLine("POST request: {0}", p.HttpUrl);
            string data = inputData.ReadToEnd();

            p.WriteSuccess();
            p.OutputStream.WriteLine("<html><body><h1>test server</h1>");
            p.OutputStream.WriteLine("<a href=/test>return</a><p>");
            p.OutputStream.WriteLine("postbody: <pre>{0}</pre>", data);
        }
예제 #2
0
        public override void HandleGetRequest(HttpProcessor p)
        {
            if (p.HttpUrl.Equals("/Test.mp3"))
            {
                Stream fs = File.Open("../../Test.mp3", FileMode.Open);

                p.WriteSuccess("Go!");
                fs.CopyTo(p.OutputStream.BaseStream);
                p.OutputStream.BaseStream.Flush();
            }

            Console.WriteLine("request: {0}", p.HttpUrl);
            p.WriteSuccess();
            p.OutputStream.WriteLine("<html><body><h1>test server</h1>");
            p.OutputStream.WriteLine("Current Time: " + DateTime.Now);
            p.OutputStream.WriteLine("url : {0}", p.HttpUrl);

            p.OutputStream.WriteLine("<form method=post action=/form>");
            p.OutputStream.WriteLine("<input type=text name=foo value=foovalue>");
            p.OutputStream.WriteLine("<input type=submit name=bar value=barvalue>");
            p.OutputStream.WriteLine("</form>");
        }
예제 #3
0
 public abstract void HandlePostRequest(HttpProcessor p, StreamReader inputData);
예제 #4
0
 public void Listen()
 {
     #pragma warning disable 618
     _listener = new TcpListener(_port);
     #pragma warning restore 618
     _listener.Start();
     while (true)
     {
         TcpClient s = _listener.AcceptTcpClient();
         HttpProcessor processor = new HttpProcessor(s, this);
         Thread thread = new Thread(processor.Process);
         thread.Start();
         Thread.Sleep(1);
     }
     // ReSharper disable once FunctionNeverReturns
 }
예제 #5
0
 public abstract void HandleGetRequest(HttpProcessor p);