使用 Node 的 Express 結(jié)合 request 來代理遠(yuǎn)程圖片,但是返回的內(nèi)容和原圖片的內(nèi)容有區(qū)別,是亂碼,但是亂的不一致。關(guān)鍵代碼:var FurionImgHandler = function (req, res) { var url = req.url.split('/fimg/')[1]; var options = { url: url }; function callback (error, response, body) { if (!error && response.statusCode === 200) { var contentType = response.headers['content-type']; response.setEncoding('binary'); res.set('Content-Type', contentType); res.send(body); } } request.get(options, callback);};原圖片:代理后返回的圖片:
Express 和 request 如何代理遠(yuǎn)程圖片?
ibeautiful
2018-11-15 14:15:37