diff --git a/lib/couchdb.js b/lib/couchdb.js index cbcdbad..9359c4a 100644 --- a/lib/couchdb.js +++ b/lib/couchdb.js @@ -4,6 +4,7 @@ var fs = require('fs'), path = require('path'), querystring = require('querystring'), + events = require('events'), mime = require('./dep/mime'), base64 = require('./dep/base64'); @@ -673,11 +674,18 @@ Db.prototype.changesStream = function(query, options) { }, options); var - stream = new process.EventEmitter(), - client = http.createClient(this.client.port, this.client.host, this.client.port == 443), + stream = new events.EventEmitter(), + agent = new http.Agent({ host: this.client.host, port: this.client.port, maxSockets: 1 }), path = '/'+this.name+'/_changes?'+exports.toQuery(query), headers = this.client._authorizationHeaders({'Host': this.client.host}), - request = client.request('GET', path, headers), + request = http.request({ + host: this.client.host, + port: this.client.port, + method: 'GET', + path: path, + headers: headers, + agent: agent + }), buffer = ''; request.setTimeout(options.timeout);