Skip to content

Commit

Permalink
add basic auth support.
Browse files Browse the repository at this point in the history
  • Loading branch information
benoitc committed Jun 30, 2010
1 parent 15c8f1b commit 2454ee4
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions lib/noddycouch/resource.js
Expand Up @@ -26,9 +26,8 @@ var Resource = function(uri) {
} else {
this.port = u.port;
}
this.host = u.hostname

this.queue = [];
this.host = u.hostname;
this.auth = u.auth || null;
};

sys.inherits(Resource, events.EventEmitter)
Expand Down Expand Up @@ -81,10 +80,17 @@ Resource.prototype.request = function(args) {
headers['content-length'] = String(payload.length);
}

var auth = options.auth || this.auth;
if (auth) headers['Authorization'] = 'Basic ' + base64.encode(auth);


// create final uri
var uri = utils.makeUri(this.url.pathname, path, params);
// prepare request
var couchdb = http.createClient(this.port, this.host);



var request = couchdb.request(method.toUpperCase(), uri, headers)

if (payload) {
Expand Down

0 comments on commit 2454ee4

Please sign in to comment.