接受的答案对我不起作用(即,将编码设置为二进制),即使是询问该问题的用户提到它也不起作用。
这是对我有用的东西,摘自:http :
//chad.pantherdev.com/node-js-binary-http-
streams/
http.get(url.parse('http://myserver.com:9999/package'), function(res) { var data = []; res.on('data', function(chunk) { data.push(chunk); }).on('end', function() { //at this point data is an array of Buffers //so Buffer.concat() can make us a new Buffer //of all of them together var buffer = Buffer.concat(data); console.log(buffer.toString('base64')); });});
编辑: 根据分号的建议更新答案
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)