465181 HttpParser delay messageComplete until after chunk trailer
This commit is contained in:
parent
a7bd9d1dd9
commit
f061ae79f4
|
@ -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);
|
||||
|
|
|
@ -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<ByteBuffer> 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
|
||||
|
|
Loading…
Reference in New Issue