Committing proper testcase for bug 440823

This commit is contained in:
Joakim Erdfelt 2014-10-11 22:51:15 -07:00
parent e7b86b99cb
commit 1511be8c97
1 changed files with 29 additions and 0 deletions

View File

@ -1483,7 +1483,36 @@ public class HttpParserTest
assertEquals("application/soap+xml; charset=utf-8; action=\"xxx\"", _val[2]);
assertEquals(2, _headers);
}
@Test
public void testParseRequest() throws Exception
{
ByteBuffer buffer = BufferUtil.toBuffer(
"GET / HTTP/1.1\r\n" +
"Host: localhost\r\n" +
"Header1: value1\r\n" +
"Connection: close\r\n" +
"Accept-Encoding: gzip, deflated\r\n" +
"Accept: unknown\r\n" +
"\r\n");
HttpParser.RequestHandler<ByteBuffer> handler = new Handler();
HttpParser parser= new HttpParser(handler);
parser.parseNext(buffer);
assertEquals("GET",_methodOrVersion);
assertEquals("/",_uriOrStatus);
assertEquals("HTTP/1.1",_versionOrReason);
assertEquals("Host",_hdr[0]);
assertEquals("localhost",_val[0]);
assertEquals("Connection",_hdr[2]);
assertEquals("close",_val[2]);
assertEquals("Accept-Encoding",_hdr[3]);
assertEquals("gzip, deflated",_val[3]);
assertEquals("Accept",_hdr[4]);
assertEquals("unknown",_val[4]);
}
@Before
public void init()