1
0
mirror of https://github.com/node-red/node-red.git synced 2023-10-10 13:36:53 +02:00

Ensure statusCode is a number

Fixes #3893

Used parseInt instead of the suggested fix so that we don't end up
with statusCode = 200.5
This commit is contained in:
Ben Hardill 2022-09-19 19:43:06 +01:00
parent f060309002
commit 4115c13a65
No known key found for this signature in database
GPG Key ID: 74DD076979ABB1E7

View File

@ -282,7 +282,7 @@ module.exports = function(RED) {
RED.nodes.createNode(this,n); RED.nodes.createNode(this,n);
var node = this; var node = this;
this.headers = n.headers||{}; this.headers = n.headers||{};
this.statusCode = n.statusCode; this.statusCode = parseInt(n.statusCode);
this.on("input",function(msg,_send,done) { this.on("input",function(msg,_send,done) {
if (msg.res) { if (msg.res) {
var headers = RED.util.cloneMessage(node.headers); var headers = RED.util.cloneMessage(node.headers);
@ -323,7 +323,7 @@ module.exports = function(RED) {
} }
} }
} }
var statusCode = node.statusCode || msg.statusCode || 200; var statusCode = node.statusCode || parseInt(msg.statusCode) || 200;
if (typeof msg.payload == "object" && !Buffer.isBuffer(msg.payload)) { if (typeof msg.payload == "object" && !Buffer.isBuffer(msg.payload)) {
msg.res._res.status(statusCode).jsonp(msg.payload); msg.res._res.status(statusCode).jsonp(msg.payload);
} else { } else {