zhangyuanwei / node-images

Cross-platform image decoder(png/jpeg/gif) and encoder(png/jpeg) for Nodejs
https://npmjs.org/package/images
MIT License
1.56k stars 205 forks source link

node-images 与 HTTP request 请求冲突 #79

Closed sp42 closed 5 years ago

sp42 commented 8 years ago

图片服务器,需要发送一个 URL 获取对方图片。但只要调用了 require("images");,就不知道为什么不能发出请求。代码没有抛出异常。

var images = require("images"); // using node-images in var var http = require("http"), url = require("url");
var siteUrl = url.parse('http://img1.gtimg.com/view/pics/hv1/42/80/2065/134297067.jpg');

var request = http.request({
method : 'HEAD',
port: siteUrl.port || 80,
host: siteUrl.host,
path : siteUrl.pathname
});
request.on('response', function (response) {
response.setEncoding('utf8');
console.log(response.headers['content-length']);
});
request.end();

sp42 commented 8 years ago

win32 正常,Centos 6.5 + node 4.4.4