Esempio n. 1
0
        public void TestRequestLine()
        {
            string requestLine = "GET FDFDadf HTTP/1.1\r\n";

            byte[] byteArray = Encoding.UTF8.GetBytes(requestLine);
            //byte[] byteArray = Encoding.ASCII.GetBytes(contents);
            MemoryStream stream = new MemoryStream(byteArray);

            WebServer.Reset();
            Assert.IsTrue(WebServer.IsValidRequestLine(stream));

            requestLine = "AET FDFDadf HTTP/1.1\r\n";
            byteArray   = Encoding.UTF8.GetBytes(requestLine);
            //byte[] byteArray = Encoding.ASCII.GetBytes(contents);
            stream = new MemoryStream(byteArray);

            WebServer.Reset();
            Assert.IsFalse(WebServer.IsValidRequestLine(stream));

            requestLine = "GET FDFDadf HTTP/2\r\n";
            byteArray   = Encoding.UTF8.GetBytes(requestLine);
            //byte[] byteArray = Encoding.ASCII.GetBytes(contents);
            stream = new MemoryStream(byteArray);

            WebServer.Reset();

            Assert.IsFalse(WebServer.IsValidRequestLine(stream));

            requestLine = "GET FDFDadfHTTP/2\r\n";
            byteArray   = Encoding.UTF8.GetBytes(requestLine);
            //byte[] byteArray = Encoding.ASCII.GetBytes(contents);
            stream = new MemoryStream(byteArray);
            WebServer.Reset();

            Assert.IsFalse(WebServer.IsValidRequestLine(stream));


            requestLine = "GET FDFDadfHTTP/2\r";
            byteArray   = Encoding.UTF8.GetBytes(requestLine);
            //byte[] byteArray = Encoding.ASCII.GetBytes(contents);
            stream = new MemoryStream(byteArray);
            WebServer.Reset();

            Assert.IsFalse(WebServer.IsValidRequestLine(stream));

            requestLine = "GETFDFDadf HTTP/2\r";
            byteArray   = Encoding.UTF8.GetBytes(requestLine);
            //byte[] byteArray = Encoding.ASCII.GetBytes(contents);
            stream = new MemoryStream(byteArray);
            WebServer.Reset();

            Assert.IsFalse(WebServer.IsValidRequestLine(stream));

            requestLine = "GET  FDFDadf HTTP/1.1\r";
            byteArray   = Encoding.UTF8.GetBytes(requestLine);
            //byte[] byteArray = Encoding.ASCII.GetBytes(contents);
            stream = new MemoryStream(byteArray);
            WebServer.Reset();

            Assert.IsFalse(WebServer.IsValidRequestLine(stream));

            requestLine = "GET \tFDFDadf HTTP/1.1\r";
            byteArray   = Encoding.UTF8.GetBytes(requestLine);
            //byte[] byteArray = Encoding.ASCII.GetBytes(contents);
            stream = new MemoryStream(byteArray);
            WebServer.Reset();

            Assert.IsFalse(WebServer.IsValidRequestLine(stream));

            requestLine = "GET\tFDFDadf HTTP/1.1\r";
            byteArray   = Encoding.UTF8.GetBytes(requestLine);
            //byte[] byteArray = Encoding.ASCII.GetBytes(contents);
            stream = new MemoryStream(byteArray);
            WebServer.Reset();

            Assert.IsFalse(WebServer.IsValidRequestLine(stream));
        }