From 30ead47ba989853ad87f0bd7f1ceb6df99a8aa17 Mon Sep 17 00:00:00 2001 From: Hiswe Date: Mon, 20 Apr 2015 16:02:18 +0700 Subject: [PATCH] fix request to couch --- lib/couchdb.js | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/lib/couchdb.js b/lib/couchdb.js index 7c9b831..669b525 100644 --- a/lib/couchdb.js +++ b/lib/couchdb.js @@ -217,7 +217,7 @@ exports.createClient = function(port, host, user, pass, maxListeners, secure) { }) .on('end', function() { var json; - httpAgent.sockets[host + ':' + port][0].emit("agentRemove"); + httpAgent.sockets[host + ':' + port + '::'][0].emit("agentRemove"); if(options.responseEncoding == 'binary') { cbFired = true; @@ -673,10 +673,13 @@ Db.prototype.changesStream = function(query, options) { var stream = new process.EventEmitter(), - client = http.createClient(this.client.port, this.client.host, this.client.port == 443), - path = '/'+this.name+'/_changes?'+exports.toQuery(query), - headers = this.client._authorizationHeaders({'Host': this.client.host}), - request = client.request('GET', path, headers), + request = http.request({ + port: this.client.port, + hostname: this.client.host, + path: '/' + this.name + '/_changes?' + exports.toQuery(query), + headers: this.client._authorizationHeaders({'Host': this.client.host}), + method: 'GET', + }), buffer = ''; request.setTimeout(options.timeout);