用我带有一个URL以 “@” 符号在里面:'@' 的URL,在node.js中http.request
curl http://subdomain:[email protected]:9292/aaa/bbb
作品完美
但我可以”不要让它与node.js http.request一起工作,可能是因为我不明白“@”在做什么(并且无法在google上找到明确的答案)。
有人在乎解释吗?
这是我目前的Node.js代码
var http_options = {
method : "GET"
, url : subdomain + ":" + token + "@" + Config.API.url
, path : "/aaa/bbb"
};
var req = http.request(http_options, function (response) {
// ...
});
req.on('error', function (error) {
console.log('error: ' + error);
});
主要生产:
error: ECONNREFUSED
你想要做的就是所谓的http-auth。这是你正在寻找的答案的另一个问题:http://stackoverflow.com/questions/6918302/http-client-based-on-nodejs-how-to-authenticate-a-request – 2012-07-25 21:16:56
所以a:b @ url是基本http-auth的简写? – Max 2012-07-25 21:19:50
非常。我需要看看RFC(s)。 – 2012-07-25 21:33:30