PerMessageDeflateDecoder Class — netty Architecture
Architecture documentation for the PerMessageDeflateDecoder class in PerMessageDeflateDecoder.java from the netty codebase.
Entity Profile
Dependency Diagram
graph TD 00e9700c_053e_cdcc_a224_1dd69bde525a["PerMessageDeflateDecoder"] 8af10425_a6dc_9556_8e16_58331b00e30e["PerMessageDeflateDecoder.java"] 00e9700c_053e_cdcc_a224_1dd69bde525a -->|defined in| 8af10425_a6dc_9556_8e16_58331b00e30e 2f8bff57_5db5_7ab4_234e_bc2343ab2a40["PerMessageDeflateDecoder()"] 00e9700c_053e_cdcc_a224_1dd69bde525a -->|method| 2f8bff57_5db5_7ab4_234e_bc2343ab2a40 0800a090_d457_2caa_7088_30039baddbe8["acceptInboundMessage()"] 00e9700c_053e_cdcc_a224_1dd69bde525a -->|method| 0800a090_d457_2caa_7088_30039baddbe8 5cb4af72_ac6e_28a2_38a1_26236eec5bfc["newRsv()"] 00e9700c_053e_cdcc_a224_1dd69bde525a -->|method| 5cb4af72_ac6e_28a2_38a1_26236eec5bfc 24b1a509_84ac_e240_c01d_6dfe380f1def["appendFrameTail()"] 00e9700c_053e_cdcc_a224_1dd69bde525a -->|method| 24b1a509_84ac_e240_c01d_6dfe380f1def 6af22f91_84ba_1689_7fa5_ec5317bb6086["decode()"] 00e9700c_053e_cdcc_a224_1dd69bde525a -->|method| 6af22f91_84ba_1689_7fa5_ec5317bb6086
Relationship Graph
Source Code
codec-http/src/main/java/io/netty/handler/codec/http/websocketx/extensions/compression/PerMessageDeflateDecoder.java lines 31–100
class PerMessageDeflateDecoder extends DeflateDecoder {
private boolean compressing;
/**
* Constructor
*
* @param noContext true to disable context takeover.
* @param maxAllocation
* maximum size of the decompression buffer. Must be >= 0. If zero, maximum size is not limited.
*/
PerMessageDeflateDecoder(boolean noContext, int maxAllocation) {
super(noContext, WebSocketExtensionFilter.NEVER_SKIP, maxAllocation);
}
/**
* Constructor
*
* @param noContext true to disable context takeover.
* @param extensionDecoderFilter extension decoder for per message deflate decoder.
* @param maxAllocation
* maximum size of the decompression buffer. Must be >= 0. If zero, maximum size is not limited.
*/
PerMessageDeflateDecoder(boolean noContext, WebSocketExtensionFilter extensionDecoderFilter, int maxAllocation) {
super(noContext, extensionDecoderFilter, maxAllocation);
}
@Override
public boolean acceptInboundMessage(Object msg) throws Exception {
if (!super.acceptInboundMessage(msg)) {
return false;
}
WebSocketFrame wsFrame = (WebSocketFrame) msg;
if (extensionDecoderFilter().mustSkip(wsFrame)) {
if (compressing) {
throw new IllegalStateException("Cannot skip per message deflate decoder, compression in progress");
}
return false;
}
return ((wsFrame instanceof TextWebSocketFrame || wsFrame instanceof BinaryWebSocketFrame) &&
(wsFrame.rsv() & WebSocketExtension.RSV1) > 0) ||
(wsFrame instanceof ContinuationWebSocketFrame && compressing);
}
@Override
protected int newRsv(WebSocketFrame msg) {
return (msg.rsv() & WebSocketExtension.RSV1) > 0?
msg.rsv() ^ WebSocketExtension.RSV1 : msg.rsv();
}
@Override
protected boolean appendFrameTail(WebSocketFrame msg) {
return msg.isFinalFragment();
}
@Override
protected void decode(ChannelHandlerContext ctx, WebSocketFrame msg,
List<Object> out) throws Exception {
super.decode(ctx, msg, out);
if (msg.isFinalFragment()) {
compressing = false;
} else if (msg instanceof TextWebSocketFrame || msg instanceof BinaryWebSocketFrame) {
compressing = true;
}
}
}
Source
Frequently Asked Questions
What is the PerMessageDeflateDecoder class?
PerMessageDeflateDecoder is a class in the netty codebase, defined in codec-http/src/main/java/io/netty/handler/codec/http/websocketx/extensions/compression/PerMessageDeflateDecoder.java.
Where is PerMessageDeflateDecoder defined?
PerMessageDeflateDecoder is defined in codec-http/src/main/java/io/netty/handler/codec/http/websocketx/extensions/compression/PerMessageDeflateDecoder.java at line 31.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free