Fixed issue: NETTY-107 - HttpMessageDecoder can not handle the content with no 'Content-Length' header.
This commit is contained in:
parent
2d682dc2a3
commit
431151b8e5
@ -103,9 +103,12 @@ public abstract class HttpMessageDecoder extends ReplayingDecoder<HttpMessageDec
|
||||
if (!mergeChunks) {
|
||||
return message;
|
||||
}
|
||||
} else if (message.getContentLength(-1) == 0) {
|
||||
content = ChannelBuffers.EMPTY_BUFFER;
|
||||
return reset();
|
||||
} else {
|
||||
int contentLength = message.getContentLength(-1);
|
||||
if (contentLength == 0 || contentLength == -1 && isDecodingRequest()) {
|
||||
content = ChannelBuffers.EMPTY_BUFFER;
|
||||
return reset();
|
||||
}
|
||||
}
|
||||
//we return null here, this forces decode to be called again where we will decode the content
|
||||
return null;
|
||||
@ -246,6 +249,7 @@ public abstract class HttpMessageDecoder extends ReplayingDecoder<HttpMessageDec
|
||||
checkpoint(nextState);
|
||||
}
|
||||
|
||||
protected abstract boolean isDecodingRequest();
|
||||
protected abstract void readInitial(ChannelBuffer buffer) throws Exception;
|
||||
|
||||
private int getChunkSize(String hex) {
|
||||
|
@ -49,4 +49,9 @@ public class HttpRequestDecoder extends HttpMessageDecoder {
|
||||
HttpVersion.valueOf(split[2]), HttpMethod.valueOf(split[0]), split[1]);
|
||||
checkpoint(State.READ_HEADER);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean isDecodingRequest() {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@ -48,4 +48,9 @@ public class HttpResponseDecoder extends HttpMessageDecoder {
|
||||
message = new DefaultHttpResponse(HttpVersion.valueOf(split[0]), new HttpResponseStatus(Integer.valueOf(split[1]), split[2]));
|
||||
checkpoint(State.READ_HEADER);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean isDecodingRequest() {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user