What about the garbled data obtained by node's http.request?

serer.js
I would like to use the following method to act as a proxy. I can get the data of the test environment locally and debug it locally.
options-related configuration

let request = http.request(options, function(response){
                response.on("data", function(chunk) {
                    data = data + chunk
                })
                response.on("end", function() {
                    try {
                        data = JSON.parse(data)
                    } catch(err) {
                        console.log(err)
                    }
                    res.json && res.json(data) || (res.body = data)
                })
            })

            request.on("error", function(e) {
                console.log("Error", e)
            })
            request.write(postdata)
            request.end()

it is normal for json, to take data from other websites in this way.
but taking the data from our company"s test environment becomes:

clipboard.png

like this.
it is normal to request a connection directly in the browser.


take a look at the encoding format from the initial message, which may be gb2312 or gbk. If so, you need to transcode

.
MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1b3326e-2b6bb.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1b3326e-2b6bb.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?