From 1bb52947e06d5047d4d9e9945137fcb8c186d581 Mon Sep 17 00:00:00 2001 From: Ryan Dahl Date: Wed, 27 Jan 2010 10:00:46 -0800 Subject: [PATCH] Forgot to include fix from HTTP client bug (30b0522) --- lib/http.js | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/lib/http.js b/lib/http.js index 32bec0d590..dcb152e987 100644 --- a/lib/http.js +++ b/lib/http.js @@ -418,6 +418,7 @@ exports.createClient = function (port, host) { var secure_credentials={ secure : false }; var requests = []; + var currentRequest; client._pushRequest = function (req) { req.addListener("flush", function () { @@ -434,7 +435,7 @@ exports.createClient = function (port, host) { return; } //sys.debug("client flush readyState = " + client.readyState); - if (req == requests[0]) flushMessageQueue(client, [req]); + if (req == currentRequest) flushMessageQueue(client, [req]); }); requests.push(req); }; @@ -451,7 +452,8 @@ exports.createClient = function (port, host) { client.addListener("connect", function () { client.resetParser(); - requests[0].flush(); + currentRequest = requests.shift(); + currentRequest.flush(); }); client.addListener("eof", function () { @@ -489,8 +491,7 @@ exports.createClient = function (port, host) { client.close(); }); - var req = requests.shift(); - req.emit("response", res); + currentRequest.emit("response", res); }); return client;