node-http-digest-client
node-http-digest-client copied to clipboard
Can not handle request error
Hi,
When request an invalid address, you may got an error like this:
events.js:72
throw er; // Unhandled 'error' event
^
Error: connect ETIMEDOUT
at errnoException (net.js:901:11)
at Object.afterConnect [as oncomplete] (net.js:892:19)
And I have no good way to handle it.
Maybe HTTPDigest.prototype.request
could return its http.ClientRequest
object. Like this:
HTTPDigest.prototype.request = function (options, callback) {
var self = this;
var req = http.request(options, function (res) {
self._handleResponse(options, res, callback);
});
req.end();
return req;
};
And to handle error like this:
var req = digest.request({
...
}, function (res) {
...
res.on('error', function (err) {
console.log('oh noes');
});
});
req.on('error', function (err) {
console.log('request error!');
});