SpdyHeaderBlockZlibDecoder extends SpdyHeaderBlockRawDecoder { @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); if (decompressor.getRemaining() != 0) { throw INVALID_HEADER_BLOCK; } headerBlock.skipBytes(len); } SpdyHeaderBlockZlibDecoder(SpdyVersion spdyVersion, int maxHeaderSize); @Override void end();  }
@Test(expected = SpdyProtocolException.class) public void testHeaderBlockExtraData() throws Exception { ByteBuf headerBlock = Unpooled.buffer(37); headerBlock.writeBytes(zlibHeader); headerBlock.writeByte(0); headerBlock.writeByte(0x15); headerBlock.writeByte(0x00); headerBlock.writeByte(0xea); headerBlock.writeByte(0xff); headerBlock.writeInt(1); headerBlock.writeInt(4); headerBlock.writeBytes(nameBytes); headerBlock.writeInt(5); headerBlock.writeBytes(valueBytes); headerBlock.writeByte(0x19); headerBlock.writeByte(0xa5); headerBlock.writeByte(0x03); headerBlock.writeByte(0xc9); headerBlock.writeByte(0); decoder.decode(ByteBufAllocator.DEFAULT, headerBlock, frame); headerBlock.release(); }
@Test(expected = SpdyProtocolException.class) public void testHeaderBlockInvalidDictionary() throws Exception { ByteBuf headerBlock = Unpooled.buffer(7); headerBlock.writeByte(0x78); headerBlock.writeByte(0x3f); headerBlock.writeByte(0x01); headerBlock.writeByte(0x02); headerBlock.writeByte(0x03); headerBlock.writeByte(0x04); headerBlock.writeByte(0); decoder.decode(ByteBufAllocator.DEFAULT, headerBlock, frame); headerBlock.release(); }
@Test(expected = SpdyProtocolException.class) public void testHeaderBlockInvalidDeflateBlock() throws Exception { ByteBuf headerBlock = Unpooled.buffer(11); headerBlock.writeBytes(zlibHeader); headerBlock.writeByte(0); headerBlock.writeByte(0x00); headerBlock.writeByte(0x00); headerBlock.writeByte(0x00); headerBlock.writeByte(0x00); decoder.decode(ByteBufAllocator.DEFAULT, headerBlock, frame); headerBlock.release(); }