Browse Source

http: fix bailout for writeHead

Reported-by: Jackson Tian <shyvo1987@gmail.com>
Reviewed-by: Trevor Norris <trev.norris@gmail.com>
v0.11.14-release
Alex Kocharin 11 years ago
committed by Trevor Norris
parent
commit
b9960eefc2
  1. 15
      lib/_http_server.js

15
lib/_http_server.js

@ -172,21 +172,20 @@ ServerResponse.prototype._implicitHeader = function() {
this.writeHead(this.statusCode); this.writeHead(this.statusCode);
}; };
ServerResponse.prototype.writeHead = function(statusCode) { ServerResponse.prototype.writeHead = function(statusCode, reason, obj) {
var headers, headerIndex; var headers;
if (util.isString(arguments[1])) { if (util.isString(reason)) {
this.statusMessage = arguments[1]; // writeHead(statusCode, reasonPhrase[, headers])
headerIndex = 2; this.statusMessage = reason;
} else { } else {
// writeHead(statusCode[, headers])
this.statusMessage = this.statusMessage =
this.statusMessage || STATUS_CODES[statusCode] || 'unknown'; this.statusMessage || STATUS_CODES[statusCode] || 'unknown';
headerIndex = 1; obj = reason;
} }
this.statusCode = statusCode; this.statusCode = statusCode;
var obj = arguments[headerIndex];
if (this._headers) { if (this._headers) {
// Slow-case: when progressive API and header fields are passed. // Slow-case: when progressive API and header fields are passed.
if (obj) { if (obj) {

Loading…
Cancel
Save