fix mocked tests
Project: http://git-wip-us.apache.org/repos/asf/couchdb-nano/repo Commit: http://git-wip-us.apache.org/repos/asf/couchdb-nano/commit/d1c7554c Tree: http://git-wip-us.apache.org/repos/asf/couchdb-nano/tree/d1c7554c Diff: http://git-wip-us.apache.org/repos/asf/couchdb-nano/diff/d1c7554c Branch: refs/heads/master Commit: d1c7554c0a9ecbab2c7c4ad3616195d3da9bbbfc Parents: 04386c1 Author: Glynn Bird <[email protected]> Authored: Wed Oct 26 11:54:56 2016 +0100 Committer: Glynn Bird <[email protected]> Committed: Wed Oct 26 11:54:56 2016 +0100 ---------------------------------------------------------------------- lib/nano.js | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/couchdb-nano/blob/d1c7554c/lib/nano.js ---------------------------------------------------------------------- diff --git a/lib/nano.js b/lib/nano.js index 9ca5137..be93a5d 100644 --- a/lib/nano.js +++ b/lib/nano.js @@ -189,8 +189,11 @@ module.exports = exports = nano = function dbScope(cfg) { return httpAgent(req); } - return httpAgent(req, function(e, h, b) { + return httpAgent(req, function(e, h, b) { rh = h && h.headers || {}; + if ( _.isEmpty(rh) ) { + rh = h && h.request && h.request.headers || {}; + } rh.statusCode = h && h.statusCode || 500; rh.uri = req.uri; @@ -440,8 +443,10 @@ module.exports = exports = nano = function dbScope(cfg) { if (e && e.statusCode !== 404) { return callback(e); } - qs.headers.Destination += '?rev=' + - h.etag.substring(1, h.etag.length - 1); + if (h.etag) { + qs.headers.Destination += '?rev=' + + h.etag.substring(1, h.etag.length - 1); + } return relax(qs, callback); }); } else {
