# HG changeset patch # User Shinji KONO # Date 1312336339 -32400 # Node ID 4116c19cd76ea50c5533e0b36bf887d69a2c2862 # Parent 462bca4c8cecdf37f61cd0135c197767cbf51a11 unzip/zip test passed. diff -r 462bca4c8cec -r 4116c19cd76e src/myVncProxy/MyRfbProto.java --- a/src/myVncProxy/MyRfbProto.java Wed Aug 03 10:30:45 2011 +0900 +++ b/src/myVncProxy/MyRfbProto.java Wed Aug 03 10:52:19 2011 +0900 @@ -525,10 +525,8 @@ * gzip byte arrays * @param deflater * @param inputs - * byte len[4] total byte length * byte data[] * @param outputs - * byte len[4] total byte length * byte data[] * @return byte length in last byte array * @throws IOException @@ -550,10 +548,8 @@ outputs.addLast(c1); len += len1; } - } while (len1 > 0); + } while (len1==INFLATE_BUFSIZE); } while(inputs.size()>0); - ByteBuffer blen = ByteBuffer.wrap(castIntByte(len)); - outputs.addFirst(blen); return len; } @@ -561,11 +557,10 @@ * gunzip byte arrays * @param inflater * @param inputs - * byte len[4] total byte length * byte data[] * @param outputs - * byte len[4] total byte length * byte data[] + *@return number of total bytes * @throws IOException */ public int unzip(Inflater inflater, LinkedList inputs, LinkedList outputs) @@ -579,8 +574,10 @@ len0 = inflater.inflate(buf.array(),0,buf.capacity()); buf.limit(len0); len += len0; - outputs.addLast(buf); - } while (len0 ==INFLATE_BUFSIZE); + if (len0>0) { + outputs.addLast(buf); + } + } while (len0>0); } while (!inputs.isEmpty()); return len; } @@ -695,7 +692,7 @@ Deflater deflater = new Deflater(); zip(deflater, in,out); unzip(inflater, out, out2); - for(ByteBuffer b:out) { + for(ByteBuffer b:in) { ByteBuffer c = out2.poll(); assertEquals(b,c); }