From 8e24a958b7f65f04f8d9d5419914a266dfca8f37 Mon Sep 17 00:00:00 2001 From: Nick O'Leary Date: Wed, 9 Jul 2014 09:43:02 +0100 Subject: [PATCH] HTTP Out - stringed the wrong bit --- nodes/core/io/21-httpin.js | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/nodes/core/io/21-httpin.js b/nodes/core/io/21-httpin.js index 2843121a2..9026c40ab 100644 --- a/nodes/core/io/21-httpin.js +++ b/nodes/core/io/21-httpin.js @@ -60,6 +60,7 @@ module.exports = function(RED) { }; this.callback = function(req,res) { +try { if (node.method == "post") { node.send({req:req,res:res,payload:req.body}); } else if (node.method == "get") { @@ -67,6 +68,10 @@ module.exports = function(RED) { } else { node.send({req:req,res:res}); } +}catch(err) { +console.log(err); +console.log(err.stack); +} } var corsHandler = function(req,res,next) { next(); } @@ -124,7 +129,13 @@ module.exports = function(RED) { msg.res.jsonp(statusCode,msg.payload); } else { if (msg.res.get('content-length') == null) { - msg.res.set('content-length', ""+Buffer.byteLength(msg.payload)); + var len; + if (typeof msg.payload == "number") { + len = Buffer.byteLength(""+msg.payload); + } else { + len = Buffer.byteLength(msg.payload); + } + msg.res.set('content-length', len); } msg.res.send(statusCode,msg.payload); }