diff --git a/jetty-http/src/main/java/org/eclipse/jetty/http/HttpParser.java b/jetty-http/src/main/java/org/eclipse/jetty/http/HttpParser.java index 0b91a5582ed..8093eb61dd6 100644 --- a/jetty-http/src/main/java/org/eclipse/jetty/http/HttpParser.java +++ b/jetty-http/src/main/java/org/eclipse/jetty/http/HttpParser.java @@ -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); diff --git a/jetty-http/src/test/java/org/eclipse/jetty/http/HttpParserTest.java b/jetty-http/src/test/java/org/eclipse/jetty/http/HttpParserTest.java index c4bcfa5f7a7..de60c40b742 100644 --- a/jetty-http/src/test/java/org/eclipse/jetty/http/HttpParserTest.java +++ b/jetty-http/src/test/java/org/eclipse/jetty/http/HttpParserTest.java @@ -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" +