http: fix bailout for writeHead
Reported-by: Jackson Tian <shyvo1987@gmail.com> Reviewed-by: Trevor Norris <trev.norris@gmail.com>
This commit is contained in:
parent
9134a3bf41
commit
b9960eefc2
@ -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) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user