JCMais / node-libcurl

libcurl bindings for Node.js
https://npmjs.org/package/node-libcurl
MIT License
660 stars 117 forks source link

HTTP_CONTENT_DECODING = false but still decodes the server's responses #393

Closed schamen closed 7 months ago

schamen commented 12 months ago

Hello Even when I use the following code curl.setOpt('HTTP_CONTENT_DECODING', false);, curl still decodes the server's responses.

The problem is that when I try to receive content-type: application/pdf, node-libcurl decodes the request incorrectly, resulting in a broken PDF file. However, when I manually download the data in base64 and decode it, the PDF file is normal. There seems to be an issue with encodings, and there is no support for UTF-16BE.

Alternatively, please suggest how to obtain a raw response from the server, encoded in base64, using the latest version 3.0.0. Thank you.

JCMais commented 7 months ago

You need to use the writefunction in this case, similar to this: https://github.com/JCMais/node-libcurl/blob/ba96d0038924b19c100dbe29ac72e3dfeda4ddff/examples/16-ftp-download.js#L24-L41