I am receiving data as an \"ZLIB\" compressed inputstream.
Using Javascript/Ajax/JQuery, I need to uncompress it on the client side.
Is the
you should see zlib rfc from:zlib rfc
the javascript inflate code I tested:inflate in Javascript the java code I wrote:
static public byte[] compress(byte[] input) {
Deflater deflater = new Deflater();
deflater.setInput(input, 0, input.length);
deflater.finish();
byte[] buff = new byte[input.length + 50];
deflater.deflate(buff);
int compressedSize = deflater.getTotalOut();
if (deflater.getTotalIn() != input.length)
return null;
byte[] output = new byte[compressedSize - 6];
System.arraycopy(buff, 2, output, 0, compressedSize - 6);// del head and
// foot byte
return output;
}
The very Important thing is in deflate in Java you must cut the head 2 byte,foot 4 byte,to get the raw deflate.