Skip to content

Commit

Permalink
Merge pull request #27 from nodejitsu/options-headers
Browse files Browse the repository at this point in the history
[api] Allow specifying headers when creating the client
  • Loading branch information
3rd-Eden committed Oct 16, 2013
2 parents 830f97c + d97920c commit d796b1c
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions node.js/lib/client/client.js
Expand Up @@ -173,6 +173,7 @@ Client.prototype.request = function (options, callback) {
var password = this.options.get('password') || this.options.get('apiToken'),
auth = new Buffer(this.options.get('username') + ':' + password).toString('base64'),
proxy = this.options.get('proxy'),
optHeaders,
self = this,
opts = {};

Expand All @@ -198,6 +199,13 @@ Client.prototype.request = function (options, callback) {
opts.headers[field] = options.headers[field];
});

optHeaders = this.options.get('headers');
if (optHeaders) {
Object.keys(optHeaders).forEach(function each(field) {
opts.headers[field] = optHeaders[field];
});
}

if (proxy) opts.proxy = proxy;

this.emit('debug::request', opts);
Expand Down

0 comments on commit d796b1c

Please sign in to comment.