Search code examples
javascriptphpcompressionzlibdeflate

Debuging a decompression error with Zlib.js


I am trying to compress text server side in PHP using the gzdeflate function and send that data to the clients browser which will then inflate it.

I did some research and found the imaya Zlib.js source on GitHub and attempted to use that. Unfortunately, I always get an "unsupported compression method" error when I try to inflate my data.

I've read the documents with no luck and I have search the web for more information.

I found these two links, but wasn't able get any positive results.
ZLIB Decompression - Client Side
Decompress gzip and zlib string in javascript

Questions:
1) Are there any tutorials on how to use these libraries available?
2) If not would anyone have any information as to why I would be getting the error message that I am?

Thanks for any help or information that you can provide.


Solution

  • http://www.php.net/manual/en/function.gzdeflate.php

    • gzencode() == gzip
    • gzcompress() == zlib (aka. HTTP deflate)
    • gzdeflate() == raw deflate encoding

    I think that you must call gzcompress() for zlib compression.