Skip to content

Commit

Permalink
http: fix bailout for writeHead
Browse files Browse the repository at this point in the history
Reported-by: Jackson Tian <shyvo1987@gmail.com>
Reviewed-by: Trevor Norris <trev.norris@gmail.com>
  • Loading branch information
rlidwka authored and trevnorris committed Aug 18, 2014
1 parent 9134a3b commit b9960ee
Showing 1 changed file with 7 additions and 8 deletions.
15 changes: 7 additions & 8 deletions lib/_http_server.js
Original file line number Diff line number Diff line change
Expand Up @@ -172,21 +172,20 @@ ServerResponse.prototype._implicitHeader = function() {
this.writeHead(this.statusCode);
};

ServerResponse.prototype.writeHead = function(statusCode) {
var headers, headerIndex;
ServerResponse.prototype.writeHead = function(statusCode, reason, obj) {
var headers;

if (util.isString(arguments[1])) {
this.statusMessage = arguments[1];
headerIndex = 2;
if (util.isString(reason)) {
// writeHead(statusCode, reasonPhrase[, headers])
this.statusMessage = reason;
} else {
// writeHead(statusCode[, headers])
this.statusMessage =
this.statusMessage || STATUS_CODES[statusCode] || 'unknown';
headerIndex = 1;
obj = reason;
}
this.statusCode = statusCode;

var obj = arguments[headerIndex];

if (this._headers) {
// Slow-case: when progressive API and header fields are passed.
if (obj) {
Expand Down

0 comments on commit b9960ee

Please sign in to comment.