Class Http1ContentDecompressor
- java.lang.Object
-
- io.netty.channel.ChannelHandlerAdapter
-
- io.netty.channel.ChannelInboundHandlerAdapter
-
- io.netty.handler.codec.MessageToMessageDecoder<io.netty.handler.codec.http.HttpObject>
-
- io.netty.handler.codec.http.HttpContentDecoder
-
- io.netty.handler.codec.http.HttpContentDecompressor
-
- org.asynchttpclient.netty.handler.Http1ContentDecompressor
-
- All Implemented Interfaces:
io.netty.channel.ChannelHandler,io.netty.channel.ChannelInboundHandler
public class Http1ContentDecompressor extends io.netty.handler.codec.http.HttpContentDecompressorHTTP/1.1 content decompressor that bounds how far a response body may inflate, mirroring whatHttp2ContentDecompressorenforces on HTTP/2 streams.Netty's own
maxAllocationargument is not such a bound. It caps the capacity of the one output buffer produced by a singleZlibDecoder.decode()call, and nothing accumulates across calls. AHC hands the decompressor oneHttpContentof at mosthttpClientCodecMaxChunkSize(8 KiB by default) at a time, so even DEFLATE's ~1032:1 ceiling keeps a single call's output around 8 MiB — under any sane limit — while the response as a whole inflates without bound. The cap therefore never fires on an ordinary decompression bomb.The counting is done inside the decoder's own
EmbeddedChannelrather than aroundHttpContentDecoder#decode: that class forwards decompressed output straight down the outer pipeline through an internal forwarder installed at the end of the embedded pipeline, so the output never passes through thedecodeout-list where it could be measured. Sitting between theZlibDecoderand that forwarder gives an exact count of what decompression produced — and only of that, so an unencoded response, which never gets a decoder, is passed through untouched and is never failed for being large; its size is the caller's own choice, not a bomb.A decoder is created per response, so each response gets a fresh counter even though this handler is shared by every response on a keep-alive connection.
-
-
Constructor Summary
Constructors Constructor Description Http1ContentDecompressor(boolean keepEncodingHeader, long maxDecompressedBytes)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected StringgetTargetContentEncoding(String contentEncoding)protected io.netty.channel.embedded.EmbeddedChannelnewContentDecoder(String contentEncoding)-
Methods inherited from class io.netty.handler.codec.http.HttpContentDecoder
channelInactive, channelReadComplete, decode, handlerAdded, handlerRemoved
-
Methods inherited from class io.netty.handler.codec.MessageToMessageDecoder
acceptInboundMessage, channelRead
-
-