mikeal/request — Issue #155: .pipe() with error status code on destination
Author: pgte
Created: 2012-01-13 13:33:44+00:00
State: open

I'm piping from a source into a destination that may return a status code indicating an error (.statusCode >= 400).
Is there any way to detect this?

For example:

var rs = request.get('http://source.com');
var ws = request.post('http://destination.com');
var error_handler = function(err) {
console.error(err);
}
rs.on('error', error_handler);
ws.on('error', error_handler);
rs.pipe(ws);

If POST http://destination.com replies with, say, a 500 status code, I never get any error.

Do I have a chance of intercepting these response status codes?