@Override public boolean hasBody() { if (bytesOut != null) { return bytesOut.writtenBytes() > 0; } else { return getBinaryFromBody().getLength() != 0; } }
@Override public boolean hasBody() { if (bytesOut != null) { return bytesOut.writtenBytes() > 0; } else { return getBinaryFromBody().getLength() != 0; } }
@Override protected ByteBuf getPayload(ChannelHandlerContext ctx, Batch batch) throws IOException { ByteBuf payload = super.getPayload(ctx, batch); try { try (ByteBufOutputStream output = new ByteBufOutputStream(ctx.alloc().buffer())) { DeflaterOutputStream outputDeflater = new DeflaterOutputStream(output, new Deflater()); byte[] chunk = new byte[payload.readableBytes()]; payload.readBytes(chunk); outputDeflater.write(chunk); outputDeflater.close(); ByteBuf content = ctx.alloc().buffer(output.writtenBytes()); content.writeByte(batch.getProtocol()); content.writeByte('C'); content.writeInt(output.writtenBytes()); content.writeBytes(output.buffer()); return content; } } finally { payload.release(); } } }
byte[] returnValue = new byte[out.writtenBytes()];