I'm developing an LSP that monitors HTTP traffic and modifies the source HTML code of every webpage. To modify HTTP response that are chunked, I used zlib
and inflate
and successfully decompressed the data using the following main line of code:
r = inflateInit2(&z, 16 + MAX_WBITS);
...
r = inflate(&z, 0);
Now, after modification, I want to re-compress the data using the exact same method, so I'm using the following line of code but it returns -2.
r = deflateInit(&o, 16 + MAX_WBITS);
If I change 16+MAX_WBITS
it returns SUCCESS
but it's not the same method and returns an invalid response after deflate
.
How can I achieve my goal?