summaryrefslogtreecommitdiff
path: root/lib/_http_server.js
diff options
context:
space:
mode:
authorcjihrig <cjihrig@gmail.com>2017-02-07 12:47:11 -0500
committercjihrig <cjihrig@gmail.com>2017-02-09 12:38:06 -0500
commita4bb9fdb893c8f2c36a6b77862e29b2608e080c2 (patch)
tree3edd4030e6a2e43bffcca32057cc45d79bf08dec /lib/_http_server.js
parentc239581e64668946cc4e95f126dc55912a2bd527 (diff)
downloadandroid-node-v8-a4bb9fdb893c8f2c36a6b77862e29b2608e080c2.tar.gz
android-node-v8-a4bb9fdb893c8f2c36a6b77862e29b2608e080c2.tar.bz2
android-node-v8-a4bb9fdb893c8f2c36a6b77862e29b2608e080c2.zip
http: include provided status code in range error
ServerResponse#writeHead() coerces the user provided status code to a number and then performs a range check. If the check fails, a range error is thrown. The coerced status code is included in the error message. This commit uses the user provided status code instead. PR-URL: https://github.com/nodejs/node/pull/11221 Reviewed-By: James M Snell <jasnell@gmail.com>
Diffstat (limited to 'lib/_http_server.js')
-rw-r--r--lib/_http_server.js4
1 files changed, 3 insertions, 1 deletions
diff --git a/lib/_http_server.js b/lib/_http_server.js
index 80880be46b..73e0b2c14a 100644
--- a/lib/_http_server.js
+++ b/lib/_http_server.js
@@ -161,9 +161,11 @@ ServerResponse.prototype._implicitHeader = function _implicitHeader() {
ServerResponse.prototype.writeHead = writeHead;
function writeHead(statusCode, reason, obj) {
+ var originalStatusCode = statusCode;
+
statusCode |= 0;
if (statusCode < 100 || statusCode > 999)
- throw new RangeError(`Invalid status code: ${statusCode}`);
+ throw new RangeError(`Invalid status code: ${originalStatusCode}`);
if (typeof reason === 'string') {
// writeHead(statusCode, reasonPhrase[, headers])