Beispiel #1
0
        public void TestHTTPHeaders()
        {
            string requestLine = "HeaderFejils: dfdf::jfjek:\r\n\r\n";

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

            WebServer.Reset();

            Assert.IsTrue(WebServer.IsValidHeader(stream));


            requestLine = "HeaderFejils : dfdf::jfjek:\r\n\r\n";
            byteArray   = Encoding.UTF8.GetBytes(requestLine);
            //byte[] byteArray = Encoding.ASCII.GetBytes(contents);
            stream = new MemoryStream(byteArray);
            WebServer.Reset();

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

            requestLine = "HeaderFejils\t: dfdf::jfjek:\r\n\r\n";
            byteArray   = Encoding.UTF8.GetBytes(requestLine);
            //byte[] byteArray = Encoding.ASCII.GetBytes(contents);
            stream = new MemoryStream(byteArray);
            WebServer.Reset();

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

            requestLine = "HeaderFejils\t:dfdf::jfjek:\r\n\r\n";
            byteArray   = Encoding.UTF8.GetBytes(requestLine);
            //byte[] byteArray = Encoding.ASCII.GetBytes(contents);
            stream = new MemoryStream(byteArray);
            WebServer.Reset();

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

            requestLine = ":HeaderFejils:dfdf::jfjek:\r\n\r\n";
            byteArray   = Encoding.UTF8.GetBytes(requestLine);
            //byte[] byteArray = Encoding.ASCII.GetBytes(contents);
            stream = new MemoryStream(byteArray);
            WebServer.Reset();

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

            requestLine = " HeaderFejils:dfdf::jfjek:\r\n\r\n";
            byteArray   = Encoding.UTF8.GetBytes(requestLine);
            //byte[] byteArray = Encoding.ASCII.GetBytes(contents);
            stream = new MemoryStream(byteArray);
            WebServer.Reset();

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