Issue #4282 HttpParser no content

Added HTTP/0.9 test

Signed-off-by: Greg Wilkins <gregw@webtide.com>
This commit is contained in:
Greg Wilkins 2019-11-11 17:27:56 +11:00
parent 3fd1daa5c8
commit ca72a8fd71
1 changed files with 33 additions and 0 deletions

View File

@ -2228,6 +2228,39 @@ public class HttpParserTest
assertNull(_bad);
}
@Test
public void testForHTTP09HeaderCompleteTrueDoesNotEmitContentComplete()
{
HttpParser.RequestHandler handler = new Handler()
{
@Override
public boolean headerComplete()
{
super.headerComplete();
return true;
}
};
HttpParser parser = new HttpParser(handler, HttpCompliance.RFC2616_LEGACY);
ByteBuffer buffer = BufferUtil.toBuffer("GET /path\r\n");
boolean handle = parser.parseNext(buffer);
assertTrue(handle);
assertFalse(buffer.hasRemaining());
assertFalse(_contentCompleted);
assertFalse(_messageCompleted);
assertEquals("GET", _methodOrVersion);
assertEquals("/path", _uriOrStatus);
assertEquals("HTTP/0.9", _versionOrReason);
assertEquals(-1, _headers);
// Need to parse more to advance the parser.
handle = parser.parseNext(buffer);
assertTrue(handle);
assertTrue(_contentCompleted);
assertTrue(_messageCompleted);
}
@Test
public void testForContentLengthZeroHeaderCompleteTrueDoesNotEmitContentComplete()
{