From cf25b2866e5cdeb8f99d6392bd2499c4d1828bf7 Mon Sep 17 00:00:00 2001 From: dceejay Date: Thu, 7 May 2015 16:45:44 +0100 Subject: [PATCH] Allow http to accept delete properly, and put, options etc. --- nodes/core/io/21-httpin.js | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/nodes/core/io/21-httpin.js b/nodes/core/io/21-httpin.js index 5ad1d5586..c17e22a4a 100644 --- a/nodes/core/io/21-httpin.js +++ b/nodes/core/io/21-httpin.js @@ -50,7 +50,7 @@ module.exports = function(RED) { this.url = n.url; this.method = n.method; - this.swaggerDoc = n.swaggerDoc; + this.swaggerDoc = n.swaggerDoc; var node = this; @@ -60,7 +60,7 @@ module.exports = function(RED) { }; this.callback = function(req,res) { - if (node.method == "post") { + if (node.method.match(/(^post$|^delete$|^put$|^options$)/)) { node.send({req:req,res:res,payload:req.body}); } else if (node.method == "get") { node.send({req:req,res:res,payload:req.query}); @@ -82,7 +82,7 @@ module.exports = function(RED) { metricsHandler = function(req, res, next) { var startAt = process.hrtime(); onHeaders(res, function() { - if(res._msgId) { + if (res._msgId) { var diff = process.hrtime(startAt); var ms = diff[0] * 1e3 + diff[1] * 1e-6; var metricResponseTime = ms.toFixed(3); @@ -103,7 +103,7 @@ module.exports = function(RED) { } else if (this.method == "put") { RED.httpNode.put(this.url,corsHandler,metricsHandler,jsonParser,urlencParser,rawBodyParser,this.callback,this.errorHandler); } else if (this.method == "delete") { - RED.httpNode.delete(this.url,corsHandler,metricsHandler,this.callback,this.errorHandler); + RED.httpNode.delete(this.url,corsHandler,metricsHandler,jsonParser,urlencParser,rawBodyParser,this.callback,this.errorHandler); } this.on("close",function() { @@ -259,7 +259,7 @@ module.exports = function(RED) { var ms = diff[0] * 1e3 + diff[1] * 1e-6; var metricRequestDurationMillis = ms.toFixed(3); node.metric("duration.millis", msg, metricRequestDurationMillis); - if(res.client && res.client.bytesRead) { + if (res.client && res.client.bytesRead) { node.metric("size.bytes", msg, res.client.bytesRead); } }