private void AcceptTcpClient(IAsyncResult ar)
        {
            var listener = (TcpListener) ar.AsyncState;
            var client = listener.EndAcceptTcpClient(ar);

            HttpProcessor processor = new HttpProcessor(client, this);
            Thread thread = new Thread(processor.process);
            thread.IsBackground = true;
            thread.Start();

            tcpCLientConnected.Set();
        }
Пример #2
0
        public override void handleGETRequest(HttpProcessor p)
        {
            if (p.http_url == "/")
            {
                p.writeSuccess();
                p.outputStream.WriteLine(File.ReadAllText("Website/index.html"));
                return;
            }

            if (!File.Exists("Website" + p.http_url))
            {
                p.writeFailure();
                return;
            }

            if(p.http_url.EndsWith(".css"))
                p.writeSuccess("text/css");
            else
                p.writeSuccess();

            p.outputStream.WriteLine(File.ReadAllText("Website" + p.http_url));
        }
Пример #3
0
 public override void handlePOSTRequest(HttpProcessor p, StreamReader inputData)
 {
     throw new NotImplementedException();
 }
 public abstract void handlePOSTRequest(HttpProcessor p, StreamReader inputData);
 public abstract void handleGETRequest(HttpProcessor p);