Browse Source

Store connection in OutgoingMessage

v0.7.4-release
Ryan Dahl 15 years ago
parent
commit
d1500cee6e
  1. 14
      lib/http.js

14
lib/http.js

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

Loading…
Cancel
Save