Browse files

Fixes #59

  • Loading branch information...
1 parent 39d1dae commit 39b4dc9464cb915796de63f44778ea0989a29d89 @disfated disfated committed Jan 7, 2012
Showing with 9 additions and 5 deletions.
  1. +9 −5 lib/restler.js
View
14 lib/restler.js
@@ -127,6 +127,10 @@ mixin(Request.prototype, {
});
}
},
+ _errorHandler: function(err) {
+ this._respond('error', null, err);
+ this._respond('complete', null, err);
+ },
_decode: function(body, response, callback) {
var encoder = response.headers['content-encoding'];
if (encoder in decoders) {
@@ -165,12 +169,12 @@ mixin(Request.prototype, {
},
_makeRequest: function() {
var self = this;
-
+
this.request.on('response', function(response) {
- self._responseHandler(response);
- }).on('error', function(err) {
- self._respond('error', null, err);
- });
+ self._responseHandler(response);
+ }).on('error', function(err) {
+ self._errorHandler(err);
+ });
},
run: function() {
var self = this;

0 comments on commit 39b4dc9

Please sign in to comment.