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

Allow http middleware to skip rawBodyParser

This commit is contained in:
Dave Conway-Jones 2016-08-28 12:02:30 +01:00
parent 5dd0622e40
commit 6868ef044b
2 changed files with 10 additions and 6 deletions

View File

@ -27,6 +27,7 @@ module.exports = function(RED) {
var isUtf8 = require('is-utf8'); var isUtf8 = require('is-utf8');
function rawBodyParser(req, res, next) { function rawBodyParser(req, res, next) {
if (req.skipRawBodyParser) { next(); } // don't parse this if told to skip
if (req._body) { return next(); } if (req._body) { return next(); }
req.body = ""; req.body = "";
req._body = true; req._body = true;
@ -55,7 +56,6 @@ module.exports = function(RED) {
if (!isText && checkUTF && isUtf8(buf)) { if (!isText && checkUTF && isUtf8(buf)) {
buf = buf.toString() buf = buf.toString()
} }
req.body = buf; req.body = buf;
next(); next();
}); });
@ -204,7 +204,6 @@ module.exports = function(RED) {
} }
var metricsHandler = function(req,res,next) { next(); } var metricsHandler = function(req,res,next) { next(); }
if (this.metric()) { if (this.metric()) {
metricsHandler = function(req, res, next) { metricsHandler = function(req, res, next) {
var startAt = process.hrtime(); var startAt = process.hrtime();

View File

@ -82,6 +82,10 @@ module.exports = {
// that should be served at http://localhost:1880/. // that should be served at http://localhost:1880/.
//httpStatic: '/home/nol/node-red-static/', //httpStatic: '/home/nol/node-red-static/',
// If you installed the optional node-red-dashboard you can set it's path
// relative to httpRoot
//ui: { path: "ui" },
// Securing Node-RED // Securing Node-RED
// ----------------- // -----------------
// To password protect the Node-RED editor and admin API, the following // To password protect the Node-RED editor and admin API, the following
@ -138,8 +142,9 @@ module.exports = {
// in front of all http in nodes. This allows custom authentication to be // in front of all http in nodes. This allows custom authentication to be
// applied to all http in nodes, or any other sort of common request processing. // applied to all http in nodes, or any other sort of common request processing.
//httpNodeMiddleware: function(req,res,next) { //httpNodeMiddleware: function(req,res,next) {
// // Handle/reject the request, or pass it on to the http in node // // Handle/reject the request, or pass it on to the http in node by calling next();
// // by calling next(); // // Optionally skip our rawBodyParser by setting this to true;
// //req.skipRawBodyParser = true;
// next(); // next();
//}, //},