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 df6decd457d..f5ff98f6a9d 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 @@ -117,6 +117,7 @@ public class HttpParser CHUNK_SIZE, CHUNK_PARAMS, CHUNK, + CHUNK_END, END, CLOSED } @@ -1453,10 +1454,7 @@ public class HttpParser if (ch == HttpTokens.LINE_FEED) { if (_chunkLength == 0) - { - setState(State.END); - return _handler.messageComplete(); - } + setState(State.CHUNK_END); else setState(State.CHUNK); } @@ -1473,10 +1471,7 @@ public class HttpParser if (ch == HttpTokens.LINE_FEED) { if (_chunkLength == 0) - { - setState(State.END); - return _handler.messageComplete(); - } + setState(State.CHUNK_END); else setState(State.CHUNK); } @@ -1507,6 +1502,20 @@ public class HttpParser break; } + case CHUNK_END: + { + // TODO handle chunk trailer + ch=next(buffer); + if (ch==0) + break; + if (ch == HttpTokens.LINE_FEED) + { + setState(State.END); + return _handler.messageComplete(); + } + throw new IllegalCharacterException(_state,ch,buffer); + } + case CLOSED: { BufferUtil.clear(buffer); 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 192293c5245..c9abb0d8687 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 @@ -582,7 +582,8 @@ public class HttpParserTest + "0123456789\015\012" + "1a\015\012" + "ABCDEFGHIJKLMNOPQRSTUVWXYZ\015\012" - + "0\015\012"); + + "0\015\012" + + "\015\012"); HttpParser.RequestHandler handler = new Handler(); HttpParser parser= new HttpParser(handler); parseAll(parser,buffer); @@ -594,6 +595,9 @@ public class HttpParserTest assertEquals("Header1", _hdr[0]); assertEquals("value1", _val[0]); assertEquals("0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ", _content); + + assertTrue(_headerCompleted); + assertTrue(_messageCompleted); } @Test