提交 19cbca0c 编写于 作者: H Harry Lachenmayer 提交者: Idan Gazit

Add HTTP basic authentication for Node.

上级 32a90439
......@@ -46,6 +46,14 @@ module.exports = function httpAdapter(resolve, reject, config) {
headers['Content-Length'] = data.length;
}
// HTTP basic authentication
var auth = undefined;
if (config.auth) {
var username = config.auth.user || config.auth.username;
var password = config.auth.pass || config.auth.password;
auth = username + ':' + password;
}
// Parse url
var parsed = url.parse(config.url);
var options = {
......@@ -54,7 +62,8 @@ module.exports = function httpAdapter(resolve, reject, config) {
path: buildURL(parsed.path, config.params, config.paramsSerializer).replace(/^\?/, ''),
method: config.method,
headers: headers,
agent: config.agent
agent: config.agent,
auth: auth
};
// Create the request
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册