public override void handlePOSTRequest(HttpProcessor p, StreamReader inputData) { Console.WriteLine("POST request: {0}", p.http_url); 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); }
public override void handleGETRequest(HttpProcessor p) { if (p.http_url.Equals("/Test.png")) { Stream fs = File.Open("../../Test.png", FileMode.Open); p.writeSuccess("image/png"); fs.CopyTo(p.outputStream.BaseStream); p.outputStream.BaseStream.Flush(); } Console.WriteLine("request: {0}", p.http_url); String response = handleRequest(p.http_url.ToString()); p.writeSuccess(); // 'answer' is the variable holding user input, so this should be the send/stored user ids string answer = p.http_url.ToUpper(); p.outputStream.WriteLine(response); }
public abstract void handleGETRequest(HttpProcessor p);
public abstract void handlePOSTRequest(HttpProcessor p, StreamReader inputData);
public void listen() { listener = new TcpListener(port); listener.Start(); while (is_active) { TcpClient s = listener.AcceptTcpClient(); HttpProcessor processor = new HttpProcessor(s, this); Thread thread = new Thread(new ThreadStart(processor.process)); thread.Start(); Thread.Sleep(1); } }