@Override
    public synchronized void compress(SpdyFrame frame, int start)
            throws IOException {
        init(frame.version);
        if (compressBuffer == null) {
            compressBuffer = new byte[frame.data.length];
        }
        //System.out.println(HexDumpListener.getHexDump(frame.data, 0, frame.endData, true, true));
        Deflater zip = zipOut;
        // last byte for flush ?
        zip.setInput(frame.data, start, frame.endData - start - 1);
        int coff = start;
        zip.setLevel(Deflater.DEFAULT_COMPRESSION);
        while (true) {
            int rd = zip.deflate(compressBuffer, coff, compressBuffer.length - coff);
            if (rd == 0) {
                // needsInput needs to be called - we're done with this frame ?
                zip.setInput(frame.data, frame.endData - 1, 1);
                zip.setLevel(Deflater.BEST_SPEED);
                while (true) {
                    rd = zip.deflate(compressBuffer, coff, compressBuffer.length - coff);
                    coff += rd;
                    if (rd == 0) {
                        break;
                    }
                    byte[] b = new byte[compressBuffer.length * 2];
                    System.arraycopy(compressBuffer, 0, b, 0, coff);
                    compressBuffer = b;
                }
                zip.setLevel(Deflater.DEFAULT_COMPRESSION);
                break;
            }
            coff += rd;
        }
        byte[] tmp = frame.data;
        frame.data = compressBuffer;
        compressBuffer = tmp;
        frame.endData = coff;
    }
@Override
    public synchronized void compress(SpdyFrame frame, int start)
            throws IOException {
        init(frame.version);
        if (compressBuffer == null) {
            compressBuffer = new byte[frame.data.length];
        }
       
        Deflater zip = zipOut;
       
        zip.setInput(frame.data, start, frame.endData - start - 1);
        int coff = start;
        zip.setLevel(Deflater.DEFAULT_COMPRESSION);
        while (true) {
            int rd = zip.deflate(compressBuffer, coff, compressBuffer.length - coff);
            if (rd == 0) {
               
                zip.setInput(frame.data, frame.endData - 1, 1);
                zip.setLevel(Deflater.BEST_SPEED);
                while (true) {
                    rd = zip.deflate(compressBuffer, coff, compressBuffer.length - coff);
                    coff += rd;
                    if (rd == 0) {
                        break;
                    }
                    byte[] b = new byte[compressBuffer.length * 2];
                    System.arraycopy(compressBuffer, 0, b, 0, coff);
                    compressBuffer = b;
                }
                zip.setLevel(Deflater.DEFAULT_COMPRESSION);
                break;
            }
            coff += rd;
        }
        byte[] tmp = frame.data;
        frame.data = compressBuffer;
        compressBuffer = tmp;
        frame.endData = coff;
    }
@override public synchronized void compress(spdyframe frame, int start) throws ioexception { init(frame.version); if (compressbuffer == null) { compressbuffer = new byte[frame.data.length]; } deflater zip = zipout; zip.setinput(frame.data, start, frame.enddata - start - 1); int coff = start; zip.setlevel(deflater.default_compression); while (true) { int rd = zip.deflate(compressbuffer, coff, compressbuffer.length - coff); if (rd == 0) { zip.setinput(frame.data, frame.enddata - 1, 1); zip.setlevel(deflater.best_speed); while (true) { rd = zip.deflate(compressbuffer, coff, compressbuffer.length - coff); coff += rd; if (rd == 0) { break; } byte[] b = new byte[compressbuffer.length * 2]; system.arraycopy(compressbuffer, 0, b, 0, coff); compressbuffer = b; } zip.setlevel(deflater.default_compression); break; } coff += rd; } byte[] tmp = frame.data; frame.data = compressbuffer; compressbuffer = tmp; frame.enddata = coff; }