* HttpMessage.isChunked() checks the 'Transfer-Encoding' header
This commit is contained in:
parent
2dab484372
commit
8c39e2823e
@ -113,7 +113,21 @@ public class DefaultHttpMessage implements HttpMessage {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public boolean isChunked() {
|
public boolean isChunked() {
|
||||||
return chunked;
|
if (chunked) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
List<String> chunked = getHeaders(HttpHeaders.Names.TRANSFER_ENCODING);
|
||||||
|
if (chunked.isEmpty()) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (String v: chunked) {
|
||||||
|
if (v.equalsIgnoreCase(HttpHeaders.Values.CHUNKED)) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setChunked(boolean chunked) {
|
public void setChunked(boolean chunked) {
|
||||||
|
@ -453,7 +453,13 @@ public abstract class HttpMessageDecoder extends ReplayingDecoder<HttpMessageDec
|
|||||||
|
|
||||||
if (isContentAlwaysEmpty(message)) {
|
if (isContentAlwaysEmpty(message)) {
|
||||||
nextState = State.SKIP_CONTROL_CHARS;
|
nextState = State.SKIP_CONTROL_CHARS;
|
||||||
} else if (isChunked(message)) {
|
} else if (message.isChunked()) {
|
||||||
|
// HttpMessage.isChunked() returns true when either:
|
||||||
|
// 1) HttpMessage.setChunked(true) was called or
|
||||||
|
// 2) 'Transfer-Encoding' is 'chunked'.
|
||||||
|
// Because this decoder did not call HttpMessage.setChunked(true)
|
||||||
|
// yet, HttpMessage.isChunked() should return true only when
|
||||||
|
// 'Transfer-Encoding' is 'chunked'.
|
||||||
nextState = State.READ_CHUNK_SIZE;
|
nextState = State.READ_CHUNK_SIZE;
|
||||||
} else if (message.getContentLength(-1) >= 0) {
|
} else if (message.getContentLength(-1) >= 0) {
|
||||||
nextState = State.READ_FIXED_LENGTH_CONTENT;
|
nextState = State.READ_FIXED_LENGTH_CONTENT;
|
||||||
@ -463,20 +469,6 @@ public abstract class HttpMessageDecoder extends ReplayingDecoder<HttpMessageDec
|
|||||||
return nextState;
|
return nextState;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static boolean isChunked(HttpMessage message) {
|
|
||||||
List<String> chunked = message.getHeaders(HttpHeaders.Names.TRANSFER_ENCODING);
|
|
||||||
if (chunked.isEmpty()) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
for (String v: chunked) {
|
|
||||||
if (v.equalsIgnoreCase(HttpHeaders.Values.CHUNKED)) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
private HttpChunkTrailer readTrailingHeaders(ChannelBuffer buffer) throws TooLongFrameException {
|
private HttpChunkTrailer readTrailingHeaders(ChannelBuffer buffer) throws TooLongFrameException {
|
||||||
headerSize = 0;
|
headerSize = 0;
|
||||||
String line = readHeader(buffer);
|
String line = readHeader(buffer);
|
||||||
|
Loading…
Reference in New Issue
Block a user