Skip to content

Commit

Permalink
Do not end request for keep-alive connections
Browse files Browse the repository at this point in the history
The request.end(data) line was preempting maintaining a persistent connection, even when Connection: 'keep-alive' was specified. My proposal is to handle the data via the body option, and only end the request when keep-alive is not specified.
  • Loading branch information
mgorczyca authored and Marianne Gorczyca committed Mar 24, 2015
1 parent 30264ac commit cf9b443
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions lib/http.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,10 @@ var httpRequest = function httpRequest(rurl, data, callback, exheaders, exoption
headers: headers,
followAllRedirects: true
};

if (headers.Connection === 'keep-alive') {
options.body = data;
}

exoptions = exoptions || {};
for (attr in exoptions) { options[attr] = exoptions[attr]; }
Expand All @@ -61,8 +65,11 @@ var httpRequest = function httpRequest(rurl, data, callback, exheaders, exoption
callback(null, res, body);
}
});
request.end(data);


if (headers.Connection !== 'keep-alive') {
request.end(data);
}

return request;
};

Expand Down

0 comments on commit cf9b443

Please sign in to comment.