var http = require('http'); module['exports'] = function recieveHttp (hook) { var hook2 = hook.open('http://hook.io/Marak/echo?foo=bar'); var hook3 = hook.open('http://hook.io/Marak/echo'); var hooks = 2; function complete() { hooks--; if (hooks === 0) { hook.res.end('hook2 and hook3 have both ended'); } } hook2.on('data', function(chunk){ hook.debug('hook2 got data' + chunk.toString()); hook.res.write(chunk.toString()); }); hook3.on('data', function(chunk){ hook.debug('hook3 got data ' + chunk.toString()); hook.res.write(chunk.toString()); }); hook2.on('end', complete); hook3.on('end', complete); hook3.write('hello'); };