Issue #346 HttpParser RFC2616 Compliance mode
Headers with no value return "" in <= RFC2616 mode
This commit is contained in:
parent
9291953380
commit
f4453ba5e0
|
@ -1174,7 +1174,7 @@ public class HttpParser
|
|||
{
|
||||
_value=null;
|
||||
_string.setLength(0);
|
||||
_valueString=null;
|
||||
_valueString=_compliance.ordinal()<=HttpCompliance.RFC2616.ordinal()?"":null;
|
||||
_length=-1;
|
||||
|
||||
setState(State.HEADER);
|
||||
|
|
|
@ -260,7 +260,7 @@ public class HttpParserTest
|
|||
"\015\012");
|
||||
|
||||
HttpParser.RequestHandler handler = new Handler();
|
||||
HttpParser parser= new HttpParser(handler,4096,HttpCompliance.RFC2616);
|
||||
HttpParser parser= new HttpParser(handler,HttpCompliance.RFC2616);
|
||||
parseAll(parser,buffer);
|
||||
|
||||
Assert.assertThat(_bad,Matchers.nullValue());
|
||||
|
@ -336,7 +336,38 @@ public class HttpParserTest
|
|||
|
||||
|
||||
@Test
|
||||
public void testNoValue() throws Exception
|
||||
public void test2616NoValue() throws Exception
|
||||
{
|
||||
ByteBuffer buffer= BufferUtil.toBuffer(
|
||||
"GET / HTTP/1.0\015\012" +
|
||||
"Host: localhost\015\012" +
|
||||
"Name0: \015\012"+
|
||||
"Name1: \015\012"+
|
||||
"Connection: close\015\012" +
|
||||
"\015\012");
|
||||
|
||||
HttpParser.RequestHandler handler = new Handler();
|
||||
HttpParser parser= new HttpParser(handler,HttpCompliance.RFC2616);
|
||||
parseAll(parser,buffer);
|
||||
|
||||
assertTrue(_headerCompleted);
|
||||
assertTrue(_messageCompleted);
|
||||
assertEquals("GET", _methodOrVersion);
|
||||
assertEquals("/", _uriOrStatus);
|
||||
assertEquals("HTTP/1.0", _versionOrReason);
|
||||
assertEquals("Host", _hdr[0]);
|
||||
assertEquals("localhost", _val[0]);
|
||||
assertEquals("Name0", _hdr[1]);
|
||||
assertEquals("", _val[1]);
|
||||
assertEquals("Name1", _hdr[2]);
|
||||
assertEquals("", _val[2]);
|
||||
assertEquals("Connection", _hdr[3]);
|
||||
assertEquals("close", _val[3]);
|
||||
assertEquals(3, _headers);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void test7230NoValue() throws Exception
|
||||
{
|
||||
ByteBuffer buffer= BufferUtil.toBuffer(
|
||||
"GET / HTTP/1.0\015\012" +
|
||||
|
|
Loading…
Reference in New Issue