【发布时间】:2011-10-18 14:22:28
【问题描述】:
这是我必须发出一个简单的 GET 请求的代码:
var options = {
host: 'localhost',
port: 8000,
path: '/restricted'
};
request = http.get(options, function(res){
var body = "";
res.on('data', function(data) {
body += data;
});
res.on('end', function() {
console.log(body);
})
res.on('error', function(e) {
console.log("Got error: " + e.message);
});
});
但“/restricted”路径需要简单的基本 HTTP 身份验证。如何添加凭据以进行身份验证?我在NodeJS' manual 中找不到与基本http 身份验证相关的任何内容。 提前致谢。
【问题讨论】:
标签: http authentication node.js restful-authentication basic-authentication