SpdyHeaderBlockZlibDecoder Class — netty Architecture
Architecture documentation for the SpdyHeaderBlockZlibDecoder class in SpdyHeaderBlockZlibDecoder.java from the netty codebase.
Entity Profile
Dependency Diagram
graph TD 3e933b4d_7bfe_3a56_91b7_1100f316848a["SpdyHeaderBlockZlibDecoder"] cca646a3_c9bc_f75f_d44a_421c3efee151["SpdyHeaderBlockZlibDecoder.java"] 3e933b4d_7bfe_3a56_91b7_1100f316848a -->|defined in| cca646a3_c9bc_f75f_d44a_421c3efee151 8c91772d_3d0a_e4d4_bdc0_9162626dc9c8["SpdyHeaderBlockZlibDecoder()"] 3e933b4d_7bfe_3a56_91b7_1100f316848a -->|method| 8c91772d_3d0a_e4d4_bdc0_9162626dc9c8 55f940f4_62a0_5f9c_ae8e_7b27e9a877bd["decode()"] 3e933b4d_7bfe_3a56_91b7_1100f316848a -->|method| 55f940f4_62a0_5f9c_ae8e_7b27e9a877bd 966094b9_d155_4bfe_119e_1f30e062e3bf["setInput()"] 3e933b4d_7bfe_3a56_91b7_1100f316848a -->|method| 966094b9_d155_4bfe_119e_1f30e062e3bf 3fcd2be6_3d2c_6c3a_7f5b_80286c53b539["decompress()"] 3e933b4d_7bfe_3a56_91b7_1100f316848a -->|method| 3fcd2be6_3d2c_6c3a_7f5b_80286c53b539 5ba07cd9_a3cb_b4ef_5ac2_3182b17a3cf7["ensureBuffer()"] 3e933b4d_7bfe_3a56_91b7_1100f316848a -->|method| 5ba07cd9_a3cb_b4ef_5ac2_3182b17a3cf7 602f19d1_23e9_8191_3632_1cd1ae0efaf8["endHeaderBlock()"] 3e933b4d_7bfe_3a56_91b7_1100f316848a -->|method| 602f19d1_23e9_8191_3632_1cd1ae0efaf8 944c56d0_0796_54d0_abaf_951c076bc6f9["end()"] 3e933b4d_7bfe_3a56_91b7_1100f316848a -->|method| 944c56d0_0796_54d0_abaf_951c076bc6f9 ceb5c934_5ce1_e70e_4b9b_9e0ab1dde4f8["releaseBuffer()"] 3e933b4d_7bfe_3a56_91b7_1100f316848a -->|method| ceb5c934_5ce1_e70e_4b9b_9e0ab1dde4f8
Relationship Graph
Source Code
codec-http/src/main/java/io/netty/handler/codec/spdy/SpdyHeaderBlockZlibDecoder.java lines 26–125
final class SpdyHeaderBlockZlibDecoder extends SpdyHeaderBlockRawDecoder {
private static final int DEFAULT_BUFFER_CAPACITY = 4096;
private static final SpdyProtocolException INVALID_HEADER_BLOCK =
new SpdyProtocolException("Invalid Header Block");
private final Inflater decompressor = new Inflater();
private ByteBuf decompressed;
SpdyHeaderBlockZlibDecoder(SpdyVersion spdyVersion, int maxHeaderSize) {
super(spdyVersion, maxHeaderSize);
}
@Override
void decode(ByteBufAllocator alloc, ByteBuf headerBlock, SpdyHeadersFrame frame) throws Exception {
int len = setInput(headerBlock);
int numBytes;
do {
numBytes = decompress(alloc, frame);
} while (numBytes > 0);
// z_stream has an internal 64-bit hold buffer
// it is always capable of consuming the entire input
if (decompressor.getRemaining() != 0) {
// we reached the end of the deflate stream
throw INVALID_HEADER_BLOCK;
}
headerBlock.skipBytes(len);
}
private int setInput(ByteBuf compressed) {
int len = compressed.readableBytes();
if (compressed.hasArray()) {
decompressor.setInput(compressed.array(), compressed.arrayOffset() + compressed.readerIndex(), len);
} else {
byte[] in = new byte[len];
compressed.getBytes(compressed.readerIndex(), in);
decompressor.setInput(in, 0, in.length);
}
return len;
}
private int decompress(ByteBufAllocator alloc, SpdyHeadersFrame frame) throws Exception {
ensureBuffer(alloc);
byte[] out = decompressed.array();
int off = decompressed.arrayOffset() + decompressed.writerIndex();
try {
int numBytes = decompressor.inflate(out, off, decompressed.writableBytes());
if (numBytes == 0 && decompressor.needsDictionary()) {
try {
decompressor.setDictionary(SPDY_DICT);
} catch (IllegalArgumentException ignored) {
throw INVALID_HEADER_BLOCK;
}
numBytes = decompressor.inflate(out, off, decompressed.writableBytes());
}
if (frame != null) {
decompressed.writerIndex(decompressed.writerIndex() + numBytes);
decodeHeaderBlock(decompressed, frame);
decompressed.discardReadBytes();
}
return numBytes;
} catch (DataFormatException e) {
throw new SpdyProtocolException("Received invalid header block", e);
}
}
private void ensureBuffer(ByteBufAllocator alloc) {
if (decompressed == null) {
decompressed = alloc.heapBuffer(DEFAULT_BUFFER_CAPACITY);
}
decompressed.ensureWritable(1);
}
@Override
Source
Frequently Asked Questions
What is the SpdyHeaderBlockZlibDecoder class?
SpdyHeaderBlockZlibDecoder is a class in the netty codebase, defined in codec-http/src/main/java/io/netty/handler/codec/spdy/SpdyHeaderBlockZlibDecoder.java.
Where is SpdyHeaderBlockZlibDecoder defined?
SpdyHeaderBlockZlibDecoder is defined in codec-http/src/main/java/io/netty/handler/codec/spdy/SpdyHeaderBlockZlibDecoder.java at line 26.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free