Fixed issue: NETTY-134 HttpChunkAggregator should not wait for content when the response status code implies empty content.

* Added HttpChunkAggregator.isContentAlwaysEmpty() and implemented it with default behavior (i.e. return true when status code is < 200, 204, 205, or 304)
This commit is contained in:
Trustin Lee 2009-03-30 02:03:01 +00:00
parent a52ce24f68
commit c511ff9872

View File

@ -65,7 +65,7 @@ public class HttpChunkAggregator extends SimpleChannelUpstreamHandler {
HttpMessage currentMessage = this.currentMessage;
if (currentMessage == null) {
HttpMessage m = (HttpMessage) msg;
if (m.isChunked()) {
if (!isContentAlwaysEmpty(m) && m.isChunked()) {
// A chunked message - remove 'Transfer-Encoding' header,
// initialize the cumulative buffer, and wait for incoming chunks.
List<String> encodings = m.getHeaders(HttpHeaders.Names.TRANSFER_ENCODING);
@ -100,4 +100,19 @@ public class HttpChunkAggregator extends SimpleChannelUpstreamHandler {
}
}
}
protected boolean isContentAlwaysEmpty(HttpMessage msg) {
if (msg instanceof HttpResponse) {
HttpResponse res = (HttpResponse) msg;
int code = res.getStatus().getCode();
if (code < 200) {
return true;
}
switch (code) {
case 204: case 205: case 304:
return true;
}
}
return false;
}
}