diff --git a/codec-http/src/main/java/io/netty/handler/codec/http/HttpContentDecompressor.java b/codec-http/src/main/java/io/netty/handler/codec/http/HttpContentDecompressor.java index c3c2ffdd64..45344677cd 100644 --- a/codec-http/src/main/java/io/netty/handler/codec/http/HttpContentDecompressor.java +++ b/codec-http/src/main/java/io/netty/handler/codec/http/HttpContentDecompressor.java @@ -16,6 +16,7 @@ package io.netty.handler.codec.http; import io.netty.channel.embedded.EmbeddedChannel; +import io.netty.handler.codec.AsciiString; import io.netty.handler.codec.compression.ZlibCodecFactory; import io.netty.handler.codec.compression.ZlibWrapper; @@ -26,6 +27,15 @@ import io.netty.handler.codec.compression.ZlibWrapper; */ public class HttpContentDecompressor extends HttpContentDecoder { + /** + * {@code "x-deflate"} + */ + private static final AsciiString X_DEFLATE = new AsciiString("x-deflate"); + /** + * {@code "x-gzip"} + */ + private static final AsciiString X_GZIP = new AsciiString("x-gzip"); + private final boolean strict; /** @@ -48,11 +58,11 @@ public class HttpContentDecompressor extends HttpContentDecoder { @Override protected EmbeddedChannel newContentDecoder(String contentEncoding) throws Exception { if (HttpHeaderValues.GZIP.equalsIgnoreCase(contentEncoding) || - HttpHeaderValues.X_GZIP.equalsIgnoreCase(contentEncoding)) { + X_GZIP.equalsIgnoreCase(contentEncoding)) { return new EmbeddedChannel(ZlibCodecFactory.newZlibDecoder(ZlibWrapper.GZIP)); } if (HttpHeaderValues.DEFLATE.equalsIgnoreCase(contentEncoding) || - HttpHeaderValues.X_DEFLATE.equalsIgnoreCase(contentEncoding)) { + X_DEFLATE.equalsIgnoreCase(contentEncoding)) { final ZlibWrapper wrapper = strict ? ZlibWrapper.ZLIB : ZlibWrapper.ZLIB_OR_NONE; // To be strict, 'deflate' means ZLIB, but some servers were not implemented correctly. return new EmbeddedChannel(ZlibCodecFactory.newZlibDecoder(wrapper)); diff --git a/codec-http/src/main/java/io/netty/handler/codec/http/HttpHeaderValues.java b/codec-http/src/main/java/io/netty/handler/codec/http/HttpHeaderValues.java index a5a27cc11b..ea907cba2b 100644 --- a/codec-http/src/main/java/io/netty/handler/codec/http/HttpHeaderValues.java +++ b/codec-http/src/main/java/io/netty/handler/codec/http/HttpHeaderValues.java @@ -188,14 +188,6 @@ public final class HttpHeaderValues { * {@code "websocket"} */ public static final AsciiString WEBSOCKET = new AsciiString("websocket"); - /** - * {@code "x-deflate"} - */ - public static final AsciiString X_DEFLATE = new AsciiString("x-deflate"); - /** - * {@code "x-gzip"} - */ - public static final AsciiString X_GZIP = new AsciiString("x-gzip"); private HttpHeaderValues() { } } diff --git a/codec-http2/src/main/java/io/netty/handler/codec/http2/DelegatingDecompressorFrameListener.java b/codec-http2/src/main/java/io/netty/handler/codec/http2/DelegatingDecompressorFrameListener.java index fdeaeb40d5..bdb0c4a019 100644 --- a/codec-http2/src/main/java/io/netty/handler/codec/http2/DelegatingDecompressorFrameListener.java +++ b/codec-http2/src/main/java/io/netty/handler/codec/http2/DelegatingDecompressorFrameListener.java @@ -30,6 +30,16 @@ import io.netty.handler.codec.http.HttpHeaderValues; * stream. */ public class DelegatingDecompressorFrameListener extends Http2FrameListenerDecorator { + + /** + * {@code "x-deflate"} + */ + private static final AsciiString X_DEFLATE = new AsciiString("x-deflate"); + /** + * {@code "x-gzip"} + */ + private static final AsciiString X_GZIP = new AsciiString("x-gzip"); + private static final Http2ConnectionAdapter CLEAN_UP_LISTENER = new Http2ConnectionAdapter() { @Override public void streamRemoved(Http2Stream stream) { @@ -121,11 +131,11 @@ public class DelegatingDecompressorFrameListener extends Http2FrameListenerDecor */ protected EmbeddedChannel newContentDecompressor(AsciiString contentEncoding) throws Http2Exception { if (HttpHeaderValues.GZIP.equalsIgnoreCase(contentEncoding) || - HttpHeaderValues.X_GZIP.equalsIgnoreCase(contentEncoding)) { + X_GZIP.equalsIgnoreCase(contentEncoding)) { return new EmbeddedChannel(ZlibCodecFactory.newZlibDecoder(ZlibWrapper.GZIP)); } if (HttpHeaderValues.DEFLATE.equalsIgnoreCase(contentEncoding) || - HttpHeaderValues.X_DEFLATE.equalsIgnoreCase(contentEncoding)) { + X_DEFLATE.equalsIgnoreCase(contentEncoding)) { final ZlibWrapper wrapper = strict ? ZlibWrapper.ZLIB : ZlibWrapper.ZLIB_OR_NONE; // To be strict, 'deflate' means ZLIB, but some servers were not implemented correctly. return new EmbeddedChannel(ZlibCodecFactory.newZlibDecoder(wrapper));