mikeal/request — Issue #123: Events are fired before listeners are added
Author: cvee
Created: 2011-12-02 04:53:27+00:00
State: open

To listen to and respond to events, one has to setup listeners as follows:

var r = request.post(postOptions);

r.on('close', function() {
// Do something
});

r.on('data', function(data) {
// Do something
});

r.on('end', function() {
// Do something
});

To configure listeners, you have to initiate the request in order to get a Request object. If the request is running, isn't it entirely possible for one or more events to be fired before the corresponding listener is added? To solve this there should be a way retrieve the Request object, add listeners and then initiate the request.