Ejemplo n.º 1
0
        public override void HandleServerSide(Socket s)
        {
            byte[] buf = new byte[1] {
                GetID()
            };
            while (buf.Last() != (byte)'\r')
            {
                buf = buf.Concat(NetUtils.Read(s, 1)).ToArray();
            }
            buf = buf.Where(c => c != (byte)'\r').ToArray();
            string req = Encoding.ASCII.GetString(buf);

            if (!req.StartsWith("GET /"))
            {
                s.Disconnect(false);
                return;
            }

            string res = HTTPParser.GetResponse(req);

            _ = s.Send(Encoding.ASCII.GetBytes(res), SocketFlags.None);
            s.Disconnect(false);
        }