A little bit of code clean up

This commit is contained in:
Trustin Lee 2009-03-04 13:50:19 +00:00
parent b676175882
commit 4979cb6a21

View File

@ -97,13 +97,15 @@ public abstract class HttpMessageDecoder extends ReplayingDecoder<HttpMessageDec
readInitial(buffer); readInitial(buffer);
} }
case READ_HEADER: { case READ_HEADER: {
readHeaders(buffer); State nextState = readHeaders(buffer);
if (message.isChunked()) { checkpoint(nextState);
checkpoint(State.READ_CHUNK_SIZE); if (nextState == State.READ_CHUNK_SIZE) {
// Chunked encoding
if (!mergeChunks) { if (!mergeChunks) {
return message; return message;
} }
} else { } else {
// Not a chunked encoding
int contentLength = message.getContentLength(-1); int contentLength = message.getContentLength(-1);
if (contentLength == 0 || contentLength == -1 && isDecodingRequest()) { if (contentLength == 0 || contentLength == -1 && isDecodingRequest()) {
content = ChannelBuffers.EMPTY_BUFFER; content = ChannelBuffers.EMPTY_BUFFER;
@ -224,7 +226,7 @@ public abstract class HttpMessageDecoder extends ReplayingDecoder<HttpMessageDec
} }
} }
private void readHeaders(ChannelBuffer buffer) { private State readHeaders(ChannelBuffer buffer) {
message.clearHeaders(); message.clearHeaders();
String line = readIntoCurrentLine(buffer); String line = readIntoCurrentLine(buffer);
String lastHeader = null; String lastHeader = null;
@ -252,7 +254,7 @@ public abstract class HttpMessageDecoder extends ReplayingDecoder<HttpMessageDec
} else { } else {
nextState = State.READ_VARIABLE_LENGTH_CONTENT; nextState = State.READ_VARIABLE_LENGTH_CONTENT;
} }
checkpoint(nextState); return nextState;
} }
protected abstract boolean isDecodingRequest(); protected abstract boolean isDecodingRequest();