nodules / asker

http.request wrapper with gzip, request retries and http.Agent tuning
MIT License
93 stars 11 forks source link

Response is not passed to callback on error #108

Closed floatdrop closed 9 years ago

floatdrop commented 9 years ago

When response is invalid (not 20x) there is no way to get response data (nor headers):

var ask = require('asker');

ask({ host : 'google.com' }, function(error, response) {
    console.error(error);
    console.log(response.data);
});

// => [AskerError: Unexpected status code {CODE:302} in
// the response for request in 63~84 ms http://google.com:80/]

/*
/Users/floatdrop/frontdays-got/ask.js:5
    console.log(response.data);
                        ^
TypeError: Cannot read property 'data' of undefined
*/
kaero commented 9 years ago

It behaves as designed. Read the manual, pls.

floatdrop commented 9 years ago

Sorry, from your presentation slides I thought that statusFilter is only affects 50x codes by default.