3
我試圖通過代理從Web訪問資源。與this response不同,我需要設置域\用戶和密碼認證。node.js http代理和域用戶:密碼授權
好了,這是我的代碼:
var http = require('http');
var options = {
host: "proxy.domain.com",
port: 80,
path: "http://www.google.com",
headers: {
Host: "www.google.com"
},
method: 'GET',
auth: 'domain\\user:password'
};
http.request(options, function (data) {
console.log('success!', data);
}).on("error", function (e) {
console.log('error :(', e);
});
上面的代碼異常觸發inmediatly以下錯誤:
error :({ [Error: getaddrinfo ENOTFOUND] code: 'ENOTFOUND', errno: 'ENOTFOUND', syscall: 'getaddrinfo' }
所以,不要求發送,我猜。
有什麼不對? 如何使用我要設置的參數發送請求?
在此先感謝