private void write(ByteBuf bb) throws IOException {
        byte[] bytes;
        int offset;
        int length = bb.readableBytes();
        if (bb.hasArray()) {
            /* avoid memory copy if possible */
            bytes = bb.array();
            offset = bb.arrayOffset();
        } else {
            bytes = new byte[length];
            bb.getBytes(bb.readerIndex(), bytes);
            offset = 0;
        }
        gzos.write(bytes, offset, length);
    }
Refactored this out of our GZipResponseFilter

User: michaels@netflix.com
Date: 5/10/16
Time: 12:31 PM
zuul-core/src/main/java/com/netflix/zuul/util/Gzipper.java