Skip to content
This repository has been archived by the owner on Apr 22, 2023. It is now read-only.

Commit

Permalink
Deprecate sendHeader() and writeHeader(), ppl should use writeHead()
Browse files Browse the repository at this point in the history
  • Loading branch information
ry committed May 12, 2010
1 parent 7a2e6d6 commit d012878
Showing 1 changed file with 24 additions and 4 deletions.
28 changes: 24 additions & 4 deletions lib/http.js
Original file line number Diff line number Diff line change
Expand Up @@ -183,8 +183,15 @@ IncomingMessage.prototype._parseQueryString = function () {
throw new Error("_parseQueryString is deprecated. Use require(\"querystring\") to parse query strings.\n");
};

var setBodyEncodingWarning;

IncomingMessage.prototype.setBodyEncoding = function (enc) {
// TODO deprecation message?
// deprecation message
if (!setBodyEncodingWarning) {
setBodyEncodingWarning = "setBodyEncoding has been renamed to setEncoding, please update your code.";
sys.error(setBodyEncodingWarning);
}

this.setEncoding(enc);
};

Expand Down Expand Up @@ -446,9 +453,22 @@ ServerResponse.prototype.writeHead = function (statusCode) {
this.headWritten = true;
};

// TODO eventually remove sendHeader(), writeHeader()
ServerResponse.prototype.sendHeader = ServerResponse.prototype.writeHead;
ServerResponse.prototype.writeHeader = ServerResponse.prototype.writeHead;
// TODO Eventually remove
var sendHeaderWarning, writeHeaderWarning;
ServerResponse.prototype.sendHeader = function () {
if (!sendHeaderWarning) {
sendHeaderWarning = "sendHeader() has been renamed to writeHead()";
sys.error(sendHeaderWarning);
}
this.writeHead.apply(this, arguments);
};
ServerResponse.prototype.writeHeader = function () {
if (!writeHeaderWarning) {
writeHeaderWarning = "writeHeader() has been renamed to writeHead()";
sys.error(writeHeaderWarning);
}
this.writeHead.apply(this, arguments);
};

function ClientRequest (socket, method, url, headers) {
OutgoingMessage.call(this, socket);
Expand Down

0 comments on commit d012878

Please sign in to comment.