Node.js proxy, dealing with gzip DEcompression

前端 未结 1 1709
予麋鹿
予麋鹿 2021-01-06 14:52

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

相关标签:
1条回答
  • 2021-01-06 15:00

    The decompressor expects binary encoded input. The chunk that your response receives is an instance of Buffer which toString() method does by default give you an UTF-8 encoded string back.

    So you have to use chunk.toString('binary') to make it work, this can also be seen in the demo.

    0 讨论(0)
提交回复
热议问题