public Payload withCompression(CompressionType requestedCompression) {
        CompressionType responseCompression = compressionInfo.getCompressionType();
        if (requestedCompression == CompressionType.UNCOMPRESSED && responseCompression == CompressionType.LZ4) {
            byte[] buffer = compressor.decompress(data.wrap(), compressionInfo.getUncompressedSize());
            Utf8Array data = new Utf8Array(buffer);
            CompressionInfo info = CompressionInfo.create(CompressionType.UNCOMPRESSED, compressionInfo.getUncompressedSize());
            return Payload.from(data, info);
        } else if (requestedCompression == CompressionType.LZ4 && responseCompression == CompressionType.UNCOMPRESSED) {
            Utf8Array data = new Utf8Array(compressor.compress(this.data.wrap()));
            CompressionInfo info = CompressionInfo.create(CompressionType.LZ4, this.data.getByteLength());
            return Payload.from(data, info);
        } else {
            return Payload.from(data, compressionInfo);
        }
    }
Returns a copy of this payload where the data is compressed using the given compression
config/src/main/java/com/yahoo/vespa/config/protocol/Payload.java