譬如请求的图片地址:http://tu.yiwu.com.cn/dw/gou08/8.jpg 我的代码是这样的: var request = require('request'); var picUrl = "http://tu.yiwu.com.cn/dw/gou08/8.jpg"; var buffers = []; request.get(picUrl) .on('response',function (resp) { console.log('response'); console.log(resp.headers['content-type']); }) .on('error',function (err) { console.log('error'); }) .on('data',function (chunk) { console.log('data'); buffers.push(chunk); }) .on('end',function () { console.log('end'); res.type('png').send(new Buffer(buffers)); });
然后这样写客户端接收到response,但不是能正确显示的图片。求大神指教~~