Support non chunked HTTP request bodies larger than Integer.MAX_VALUE.
Motivation: Request bodies can easily be larger than Integer.MAX_VALUE in practice. There's no reason, or intention, for Netty to impose this artificial constraint. Worse, it currently does not fail if the body is larger than this value; it just silently only reads the first Integer.MAX_VALUE bytes and discards the rest. This restriction doesn't effect chunked transfers, with no Content-Length header. Modifications: Force the use of `long HttpUtil.getContentLength(HttpMessage, long)` instead of `long HttpUtil.getContentLength(HttpMessage, long)`. Result: Netty will support HTTP request bodies of up to Long.MAX_VALUE length.
This commit is contained in:
parent
f990f9983d
commit
d97f17060f
@ -114,13 +114,13 @@ public class HttpObjectAggregator
|
||||
|
||||
@Override
|
||||
protected boolean isContentLengthInvalid(HttpMessage start, int maxContentLength) {
|
||||
return getContentLength(start, -1) > maxContentLength;
|
||||
return getContentLength(start, -1L) > maxContentLength;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Object newContinueResponse(HttpMessage start, int maxContentLength, ChannelPipeline pipeline) {
|
||||
if (HttpUtil.is100ContinueExpected(start)) {
|
||||
if (getContentLength(start, -1) <= maxContentLength) {
|
||||
if (getContentLength(start, -1L) <= maxContentLength) {
|
||||
return CONTINUE.duplicate().retain();
|
||||
}
|
||||
|
||||
|
@ -602,7 +602,7 @@ public abstract class HttpObjectDecoder extends ByteToMessageDecoder {
|
||||
|
||||
private long contentLength() {
|
||||
if (contentLength == Long.MIN_VALUE) {
|
||||
contentLength = HttpUtil.getContentLength(message, -1);
|
||||
contentLength = HttpUtil.getContentLength(message, -1L);
|
||||
}
|
||||
return contentLength;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user