Skip to content
Browse files

Switch from onResponse:true to on("response", ...)

  • Loading branch information...
1 parent 0b874a0 commit cb44f26c15d7cda4340dde8459adc58b5479dce1 @jhs jhs committed Mar 19, 2013
Showing with 11 additions and 4 deletions.
  1. +5 −2 lib/feed.js
  2. +6 −2 test/stream.js
View
7 lib/feed.js
@@ -187,7 +187,6 @@ Feed.prototype.query = function query_feed() {
, uri : feed_url
, headers: self.headers
, encoding: 'utf-8'
- , onResponse: on_feed_response
}
req.changes_query = query_params;
@@ -201,9 +200,13 @@ Feed.prototype.query = function query_feed() {
self.log.debug('Feed query ' + feed_id + ': ' + lib.scrub_creds(feed_url))
var feed_request = request(req)
- feed_request.on('response', function() {
+
+ feed_request.on('response', function(res) {
self.log.debug('Remove feed from agent pool: ' + feed_id)
feed_request.req.socket.emit('agentRemove')
+
+ // Simulate the old onResponse option.
+ on_feed_response(null, res, res.body)
})
// The response headers must arrive within one heartbeat.
View
8 test/stream.js
@@ -375,7 +375,10 @@ test('Feeds from couch', function(t) {
feed.on('end', function() { events.push('END') })
var uri = couch.DB + '/_changes?feed=' + type
- var req = request({'uri':uri, 'onResponse':true}, on_response)
+ var req = request({'uri':uri})
+
+ // Compatibility with the old onResponse option.
+ req.on('response', function(res) { on_response(null, res, res.body) })
// Disconnect the continuous feed after a while.
if(type == 'continuous')
@@ -490,7 +493,8 @@ test('Pausing and destroying a feed mid-stream', function(t) {
if(type == 'continuous')
uri += '&heartbeat=' + Math.floor(couch.rtt())
- var req = request({'uri':uri, 'onResponse':feed_response})
+ var req = request({'uri':uri})
+ req.on('response', function(res) { feed_response(null, res, res.body) })
req.on('error', function(er) { ev('request', er) })
req.on('close', function() { ev('request', 'close') })
req.on('data', function(d) { ev('request', d) })

0 comments on commit cb44f26

Please sign in to comment.
Something went wrong with that request. Please try again.