diff --git a/src/main/java/org/jboss/netty/handler/codec/http/HttpContentDecoder.java b/src/main/java/org/jboss/netty/handler/codec/http/HttpContentDecoder.java index 06f9068b72..410d5458c2 100644 --- a/src/main/java/org/jboss/netty/handler/codec/http/HttpContentDecoder.java +++ b/src/main/java/org/jboss/netty/handler/codec/http/HttpContentDecoder.java @@ -79,9 +79,14 @@ public abstract class HttpContentDecoder extends SimpleChannelUpstreamHandler if (hasContent && (decoder = newContentDecoder(contentEncoding)) != null) { // Decode the content and remove or replace the existing headers // so that the message looks like a decoded message. - m.setHeader( - HttpHeaders.Names.CONTENT_ENCODING, - getTargetContentEncoding(contentEncoding)); + String targetContentEncoding = getTargetContentEncoding(contentEncoding); + if (HttpHeaders.Values.IDENTITY.equals(targetContentEncoding)) { + // Do NOT set the 'Content-Encoding' header if the target encoding is 'identity' + // as per: http://tools.ietf.org/html/rfc2616#section-14.11 + m.removeHeader(HttpHeaders.Names.CONTENT_ENCODING); + } else { + m.setHeader(HttpHeaders.Names.CONTENT_ENCODING, targetContentEncoding); + } if (!m.isChunked()) { ChannelBuffer content = m.getContent();