private synchronized ByteBuf compressHeaderBlock(ByteBuf uncompressed) throws Exception { if (uncompressed.readableBytes() == 0) { return Unpooled.EMPTY_BUFFER; } ByteBuf compressed = Unpooled.buffer(); synchronized (headerBlockCompressor) { if (!finished) { headerBlockCompressor.setInput(uncompressed); headerBlockCompressor.encode(compressed); } } return compressed; }
/** Creates a new instance with the specified parameters. */ public SpdyFrameEncoder(int version, int compressionLevel, int windowBits, int memLevel) { if (version < SpdyConstants.SPDY_MIN_VERSION || version > SpdyConstants.SPDY_MAX_VERSION) { throw new IllegalArgumentException("unknown version: " + version); } this.version = version; headerBlockCompressor = SpdyHeaderBlockCompressor.newInstance(version, compressionLevel, windowBits, memLevel); }