delayed-response
Buffer an HTTP response and execute a function before flushing
Install
$ npm install --save delayed-response
Usage
var DelayedResponse = server { console }
API
DelayedResponse(req, res, callback)
-> object
Returns a delayed
instance which proxies an http.ServerResponse. Delayed responses emit errors returned from the supplied callback
. Make sure to handle the 'error'
event on your response or use an abstraction like pump.
req
Required
Type: object
res
Required
Type: object
The original http.ServerResponse
.
callback
Required
Type: function
Arguments: req, delayed, buffer, done
A callback to call with the delayed response, the full data buffer (a Buffer
), and a done
function. Passing an error to done
will cause the delayed request to reset the original response headers and then emit an error. Otherwise, the buffered data is re-sent.
License
MIT © Ben Drucker