コード例 #1
0
        public void TestValidPartialValueResponse()
        {
            var header1 = "HTTP/1.1 200 OK\r\n" +
                          "Date: Mon, 27 Jul 2009 12:28:53 GMT\r\n" +
                          "Server: Apache\r\n" +
                          "Last-Modified: Wed, 22 Jul 2";
            var header2 = header1 + "009 19:15:56 GMT\r\n" +
                          "ETag: \"34aa387-d-1568eb00\"\r\n" +
                          "Accept-Ranges: bytes\r\n" +
                          "Content-Length: 0\r\n" +
                          "Vary: Accept-Encoding\r\n" +
                          "Content-Type: text/plain\r\n\r\n";
            var parser = new HttpHeaderParser();
            var stream = new ByteArray(ASCIIEncoding.ASCII.GetBytes(header1));

            parser.Parse(stream, true);
            Assert.Equal("Mon, 27 Jul 2009 12:28:53 GMT", parser.GetHeader("Date"));
            Assert.Equal("Apache", parser.GetHeader("Server"));
            Assert.Null(parser.GetHeader("Last-Modi"));
            Assert.Null(parser.GetHeader("Last-Modified"));
            stream = new ByteArray(ASCIIEncoding.ASCII.GetBytes(header2));
            parser.Parse(stream, true);
            Assert.Equal("Apache", parser.GetHeader("Server"));
            Assert.Equal("Wed, 22 Jul 2009 19:15:56 GMT", parser.GetHeader("Last-Modified"));
            Assert.Equal("\"34aa387-d-1568eb00\"", parser.GetHeader("ETag"));

            var data = parser.Create(stream, EmptyData.Instance);
        }