3

I'm currently working on a proxy server where we in this case have to modify the data (by using regexp) that we push through it.

In most cases it works fine except for websites that use gzip as content-encoding (I think), I've come across a module called compress and tried to push the chunks that I receive through a decompress / gunzip stream but it isn't really turning out as I expected.

I was wondering if I am at all heading in the right direction, and if there are more modules out there to make my life easier (regarding gzip compression).

Greetz,

Benjamin

M0rph3v5
  • 945
  • 1
  • 11
  • 23
  • What do you mean "not turning out as expected"? With gzip (or any kind of lossless compression) it usually either works or doesn't work and you end up with useless gibberish. If that is the case, it is likely an encoding issue. You cannot send a `utf8` stream to a decompression module and expect it to decompress cleanly. The stream must remain in its native `Buffer` format. – MooGoo Jan 03 '11 at 16:21

3 Answers3

8

If you think your proxy is just for filtering or modifying text, you feel verbose about gzip compression and decompression.

Another solution is simple.
Modify http request header. Then you can get plain text from server.

Remove 'Accept-Encoding' from http request header.

SOnDDinG
  • 81
  • 1
  • 2
3

See here: Node.js proxy, dealing with gzip DEcompression

For an answer that covered most of my problems.

Community
  • 1
  • 1
M0rph3v5
  • 945
  • 1
  • 11
  • 23
0

Have a look there: Node.js: Gzip compression?

There is a alternative to using node-compress, but this solution is also mentioned.

Cheers,

-stan

Community
  • 1
  • 1
spolu
  • 680
  • 5
  • 11