diff --git a/lib/adapters/http.js b/lib/adapters/http.js index 30e3ccc7ea8bcd5b9e0f2cb3e8e40a0be674e815..740a9dcbe702bd6883812e6e6339ba58c2d1f3fb 100644 --- a/lib/adapters/http.js +++ b/lib/adapters/http.js @@ -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