mirror of
https://github.com/nodejs/node.git
synced 2026-10-14 10:26:26 -04:00
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>
This commit is contained in:
1 parent
c239581e64
commit
a4bb9fdb89
2 files changed
+13
-11
No files matched your search
+3
-1
@@ -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])
|
||||
|
||||
Reference in new issue
Block a user