0

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?

Javid
  • 2,755
  • 2
  • 33
  • 60

1 Answers1

1

You need to use deflateInit2(). The fourth argument would be the 16 + MAX_WBITS. Please read the documentation in zlib.h

rene
  • 41,474
  • 78
  • 114
  • 152
Mark Adler
  • 101,978
  • 13
  • 118
  • 158