Browse Source

Add an error listener to prevent socket hang up and similar errors leading to thrown exceptions.

pull/4/head
Reason 12 years ago
parent
commit
759218c021
1 changed files with 8 additions and 0 deletions
  1. +8
    -0
      lib/http_client.js

+ 8
- 0
lib/http_client.js View File

@ -128,6 +128,14 @@ client.prototype.request = function(method, path, params, callback){
});
});
// This should only occur for errors such as a socket hang up prior to any
// data being received, or SSL-related issues.
req.on('error', function(err) {
if(typeof callback == 'function'){
callback(err, null, 0);
}
});
if(['POST', 'PUT'].indexOf(http_options['method']) >= 0){
req.write(body);
}


Loading…
Cancel
Save