Fixed a problem where the last chunk is decoded too early

This commit is contained in:
Trustin Lee 2009-02-12 06:27:17 +00:00
parent ebe77cef21
commit 602c99c532

View File

@ -132,12 +132,7 @@ public abstract class HttpMessageDecoder extends ReplayingDecoder<HttpMessageDec
chunkSize = getChunkSize(line); chunkSize = getChunkSize(line);
if (chunkSize == 0) { if (chunkSize == 0) {
checkpoint(State.READ_CHUNK_FOOTER); checkpoint(State.READ_CHUNK_FOOTER);
if (mergeChunks) {
return null; return null;
} else {
HttpChunk lastChunk = new DefaultHttpChunk(EMPTY_BUFFER);
return lastChunk;
}
} else { } else {
checkpoint(State.READ_CHUNKED_CONTENT); checkpoint(State.READ_CHUNKED_CONTENT);
} }
@ -177,6 +172,8 @@ public abstract class HttpMessageDecoder extends ReplayingDecoder<HttpMessageDec
return reset(); return reset();
} else { } else {
reset(); reset();
// The last chunk, which is empty
return new DefaultHttpChunk(EMPTY_BUFFER);
} }
} else { } else {
checkpoint(State.READ_CHUNK_FOOTER); checkpoint(State.READ_CHUNK_FOOTER);