EmbeddedChannel decompressor = stream.decompressor();
if (decompressor == null) {
if (!endOfStream) {
// Determine the content encoding.
AsciiString contentEncoding = headers.get(HttpHeaderNames.CONTENT_ENCODING);
if (contentEncoding == null) {
contentEncoding = HttpHeaderValues.IDENTITY;
}
decompressor = newContentDecompressor(contentEncoding);
if (decompressor != null) {
stream.decompressor(decompressor);
// Decode the content and remove or replace the existing headers
// so that the message looks like a decoded message.
AsciiString targetContentEncoding = getTargetContentEncoding(contentEncoding);
if (HttpHeaderValues.IDENTITY.equalsIgnoreCase(targetContentEncoding)) {
headers.remove(HttpHeaderNames.CONTENT_ENCODING);
} else {
headers.set(HttpHeaderNames.CONTENT_ENCODING, targetContentEncoding);
}