Added HttpContentDecoder.getTargetEncoding
This commit is contained in:
parent
d450f0a228
commit
bc6b84e58b
@ -78,7 +78,9 @@ public abstract class HttpContentDecoder extends SimpleChannelUpstreamHandler {
|
|||||||
if (contentEncoding != null && (decoder = newDecoder(contentEncoding)) != null) {
|
if (contentEncoding != null && (decoder = newDecoder(contentEncoding)) != null) {
|
||||||
// Decode the content and remove or replace the existing headers
|
// Decode the content and remove or replace the existing headers
|
||||||
// so that the message looks like a decoded message.
|
// so that the message looks like a decoded message.
|
||||||
m.setHeader(HttpHeaders.Names.CONTENT_ENCODING, HttpHeaders.Values.IDENTITY);
|
m.setHeader(
|
||||||
|
HttpHeaders.Names.CONTENT_ENCODING,
|
||||||
|
getTargetEncoding(contentEncoding));
|
||||||
|
|
||||||
if (!m.isChunked()) {
|
if (!m.isChunked()) {
|
||||||
ChannelBuffer content = m.getContent();
|
ChannelBuffer content = m.getContent();
|
||||||
@ -165,6 +167,18 @@ public abstract class HttpContentDecoder extends SimpleChannelUpstreamHandler {
|
|||||||
*/
|
*/
|
||||||
protected abstract DecoderEmbedder<ChannelBuffer> newDecoder(String contentEncoding) throws Exception;
|
protected abstract DecoderEmbedder<ChannelBuffer> newDecoder(String contentEncoding) throws Exception;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the expected content encoding of the decoded content.
|
||||||
|
* This method returns {@code "identity"} by default, which is the case for
|
||||||
|
* most decoders.
|
||||||
|
*
|
||||||
|
* @param contentEncoding the content encoding of the original content
|
||||||
|
* @return the expected content encoding of the new content
|
||||||
|
*/
|
||||||
|
protected String getTargetEncoding(String contentEncoding) throws Exception {
|
||||||
|
return HttpHeaders.Values.IDENTITY;
|
||||||
|
}
|
||||||
|
|
||||||
private ChannelBuffer decode(ChannelBuffer buf) {
|
private ChannelBuffer decode(ChannelBuffer buf) {
|
||||||
decoder.offer(buf);
|
decoder.offer(buf);
|
||||||
return pollDecodeResult();
|
return pollDecodeResult();
|
||||||
|
Loading…
Reference in New Issue
Block a user