Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

fixed a bug in the promise based http client

Fixed a bug in the promise based http client where the timeout would try to
call the destroy method of an undefined client object which was probably
intended to be the request object.
  • Loading branch information...
commit 6bbf1677df6f3193fc1f8c6c1482219a9f18e174 1 parent 48cb696
Alexandru Bularca authored
Showing with 6 additions and 4 deletions.
  1. +6 −4 engines/node/http-client.js
View
10 engines/node/http-client.js
@@ -19,7 +19,7 @@ exports.request = function(originalRequest){
request[key] = originalRequest[key];
}
}
-
+
if(request.timeout === undefined)request.timeout= 20000; // default timeout.
if(request.url){
var parsed = parse(request.url);
@@ -37,7 +37,7 @@ exports.request = function(originalRequest){
if(exports.proxyServer){
request.pathname = request.url;
var proxySettings = parse(exports.proxyServer);
- request.port = proxySettings.port;
+ request.port = proxySettings.port;
request.protocol = proxySettings.protocol;
request.hostname = proxySettings.hostname;
}
@@ -49,7 +49,7 @@ exports.request = function(originalRequest){
// No timeout is used on the client stream, but we do destroy the stream if a timeout is reached.
var timeout = setTimeout(function(){
timedOut = true;
- client.destroy();
+ req.destroy();
deferred.reject(new Error("Timeout"));
}, request.timeout);
@@ -94,7 +94,9 @@ exports.request = function(originalRequest){
clearTimeout(timeout);
});
req.on('error', function(e) {
- deferred.reject(e);
+ if (!timedOut) {
+ deferred.reject(e);
+ }
});
if(request.body){
return when(request.body.forEach(function(block){
Please sign in to comment.
Something went wrong with that request. Please try again.