diff --git a/lib/http.js b/lib/http.js index 33cab5143e..ca196bc176 100644 --- a/lib/http.js +++ b/lib/http.js @@ -96,8 +96,10 @@ IncomingMessage.prototype._addHeaderLine = function (field, value) { } }; -function OutgoingMessage () { - events.EventEmitter.call(this); +function OutgoingMessage (connection) { + events.EventEmitter.call(this, connection); + + this.connection = connection; this.output = []; this.outputEncodings = []; @@ -246,7 +248,7 @@ OutgoingMessage.prototype.close = function () { function ServerResponse (req) { - OutgoingMessage.call(this); + OutgoingMessage.call(this, req.connection); if (req.httpVersionMajor < 1 || req.httpVersionMinor < 1) { this.use_chunked_encoding_by_default = false; @@ -283,8 +285,8 @@ ServerResponse.prototype.writeHead = function (statusCode) { ServerResponse.prototype.sendHeader = ServerResponse.prototype.writeHead; ServerResponse.prototype.writeHeader = ServerResponse.prototype.writeHead; -function ClientRequest (method, url, headers) { - OutgoingMessage.call(this); +function ClientRequest (connection, method, url, headers) { + OutgoingMessage.call(this, connection); this.should_keep_alive = false; if (method === "GET" || method === "HEAD") { @@ -559,7 +561,7 @@ process.http.Client.prototype.request = function (method, url, headers) { url = method; method = null; } - var req = new ClientRequest(method || "GET", url, headers); + var req = new ClientRequest(this, method || "GET", url, headers); this._pushRequest(req); return req; };