2020年12月23日星期三

Nodejs and Python http response encoding discrepancy

I make a call through a proxy from node and from python. My python return string is:

Â\xad¾l«|Ä}\x84\x85}|\x81\x84\x80\x82\x81«l\x89l²Áº¯Àµ»ºt«¿uÇÂ\xad¾l¿\x89}x¾\x89§

when printed in the context of the entire response. when it is focused, it becomes

­¾l«|Ä}„…}|„€‚«l‰l²Áº¯Àµ»ºt«¿uÇ (as an example, the slicing may be off)

however, in node.js, the string prints as

\u001f\ufffd\u0008\u0000\u0000\u0000\u0000\u0000\u0000\u0003\u0000\u0000\u0000\ufffd\ufffd\ufffd]\tw\

in the context of the body, and

����Cqg)�=�O��  ����Q�d2Q�4�2��"���]�r(  

when focused. I would like for nodejs to create the same outputs as python, how can i do so?

python is deserialized via request.text while nodejs uses the fetch api and response.text() respectively

The server does not return any headers, only a body. in the json format

{"Headers":"{stringified: headers}", "Body":"texthere"}

I do not understand why the top prints raw utf, but the bottom prints as unicode format

https://stackoverflow.com/questions/65433034/nodejs-and-python-http-response-encoding-discrepancy December 24, 2020 at 09:49AM

没有评论:

发表评论