These are chat archives for request/request

Jun 2015
Aldwin Vlasblom
Jun 05 2015 12:55
Hey, I'm wondering how to handle 404 when requesting an image for piping. I pipe the response into GrahpicsMagick for analysis but when 404 is returned from the server (in a non-image format), GraphicsMagick breaks my app.
If I listen to the 'response' event, I'm already too late to decide whether to pipe or not.
I guess I would have to make a HEAD request first?
Jun 05 2015 14:08
this may help you
@Avaq request
.on('response', function(response) {
console.log(response.statusCode) // 200
console.log(response.headers['content-type']) // 'image/png'