summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlex Kocharin <alex@kocharin.ru>2014-08-14 18:54:44 +0400
committerTrevor Norris <trev.norris@gmail.com>2014-08-18 16:21:03 -0700
commitb9960eefc2093ea639353171189652b7cf116326 (patch)
treee8b3f73cb9f5081b9e519e57589acec38be0989d
parent9134a3bf413fe7e498e75ea3d6ad7d6f33040f68 (diff)
downloadnodejs-b9960eefc2093ea639353171189652b7cf116326.tar.gz
nodejs-b9960eefc2093ea639353171189652b7cf116326.tar.bz2
nodejs-b9960eefc2093ea639353171189652b7cf116326.zip
http: fix bailout for writeHead
Reported-by: Jackson Tian <shyvo1987@gmail.com> Reviewed-by: Trevor Norris <trev.norris@gmail.com>
-rw-r--r--lib/_http_server.js15
1 files changed, 7 insertions, 8 deletions
diff --git a/lib/_http_server.js b/lib/_http_server.js
index bcb014129..83cab6908 100644
--- a/lib/_http_server.js
+++ b/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) {