用我帶有一個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