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);
};
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…
Cancel
Save