* Removed the usage of unnecessary state variable

* Renamed READ_CRLF to READ_END_OF_CHUNK
This commit is contained in:
Trustin Lee 2009-02-12 05:28:55 +00:00
parent 66423e0c1d
commit fb74832dc8

View File

@ -65,11 +65,9 @@ public abstract class HttpMessageDecoder extends ReplayingDecoder<HttpMessageDec
READ_FIXED_LENGTH_CONTENT, READ_FIXED_LENGTH_CONTENT,
READ_CHUNK_SIZE, READ_CHUNK_SIZE,
READ_CHUNKED_CONTENT, READ_CHUNKED_CONTENT,
READ_CRLF; READ_END_OF_CHUNK;
} }
private State nextState;
protected HttpMessageDecoder() { protected HttpMessageDecoder() {
super(State.SKIP_CONTROL_CHARS); super(State.SKIP_CONTROL_CHARS);
} }
@ -135,12 +133,12 @@ public abstract class HttpMessageDecoder extends ReplayingDecoder<HttpMessageDec
case READ_CHUNKED_CONTENT: { case READ_CHUNKED_CONTENT: {
readChunkedContent(channel, buffer); readChunkedContent(channel, buffer);
} }
case READ_CRLF: { case READ_END_OF_CHUNK: {
byte next = buffer.readByte(); byte next = buffer.readByte();
if (next == HttpCodecUtil.CR) { if (next == HttpCodecUtil.CR) {
buffer.readByte(); buffer.readByte();
} }
checkpoint(nextState); checkpoint(State.READ_CHUNK_SIZE);
return null; return null;
} }
default: { default: {
@ -153,7 +151,6 @@ public abstract class HttpMessageDecoder extends ReplayingDecoder<HttpMessageDec
private Object reset() { private Object reset() {
message.setContent(content); message.setContent(content);
content = null; content = null;
nextState = null;
checkpoint(State.SKIP_CONTROL_CHARS); checkpoint(State.SKIP_CONTROL_CHARS);
return message; return message;
} }
@ -175,8 +172,7 @@ public abstract class HttpMessageDecoder extends ReplayingDecoder<HttpMessageDec
chunkSize, channel.getConfig().getBufferFactory()); chunkSize, channel.getConfig().getBufferFactory());
} }
content.writeBytes(buffer, chunkSize); content.writeBytes(buffer, chunkSize);
nextState = State.READ_CHUNK_SIZE; checkpoint(State.READ_END_OF_CHUNK);
checkpoint(State.READ_CRLF);
} }
private void readFixedLengthContent(ChannelBuffer buffer) { private void readFixedLengthContent(ChannelBuffer buffer) {