diff --git a/CHANGES_NEXT_RELEASE b/CHANGES_NEXT_RELEASE index 0d4ce7bcd..1e8ae7492 100644 --- a/CHANGES_NEXT_RELEASE +++ b/CHANGES_NEXT_RELEASE @@ -1 +1,2 @@ - Fix: allow send multiple measures to CB in a batch (v2/op/update) instead of using multiples single request (iotagent-json#825) +- Fix: default express limit to 1Mb instead default 100Kb and allow change it throught a conf env var 'IOTA_EXPRESS_LIMIT' (#827) \ No newline at end of file diff --git a/lib/bindings/HTTPBinding.js b/lib/bindings/HTTPBinding.js index 321ae7fe5..071c0c1af 100644 --- a/lib/bindings/HTTPBinding.js +++ b/lib/bindings/HTTPBinding.js @@ -52,9 +52,9 @@ let httpBindingServer; const transport = 'HTTP'; const { promisify } = require('util'); -const json = promisify(bodyParser.json({ strict: false })); // accept anything JSON.parse accepts. -const text = promisify(bodyParser.text()); -const raw = promisify(bodyParser.raw()); +const json = promisify(bodyParser.json({ strict: false, limit: config.getConfig().iota.expressLimit })); // accept anything JSON.parse accepts. +const text = promisify(bodyParser.text({ limit: config.getConfig().iota.expressLimit })); +const raw = promisify(bodyParser.raw({ limit: config.getConfig().iota.expressLimit })); const xml2js = require('xml2js'); const xmlStripPrefix = xml2js.processors.stripPrefix; const xml = promisify( @@ -674,7 +674,7 @@ function start(callback) { httpBindingServer.router.post( config.getConfig().iota.defaultResource || constants.HTTP_MEASURE_PATH, - bodyParser.json({ strict: false }), // accept anything JSON.parse accepts + bodyParser.json({ strict: false, limit: config.getConfig().iota.expressLimit }), // accept anything JSON.parse accepts checkMandatoryParams(false), parseDataMultipleMeasure, addTimestamp, @@ -697,7 +697,7 @@ function start(callback) { httpBindingServer.router.post( (config.getConfig().iota.defaultResource || constants.HTTP_MEASURE_PATH) + constants.HTTP_COMMANDS_PATH, - bodyParser.json({ strict: false }), // accept anything JSON.parse accepts. + bodyParser.json({ strict: false, limit: config.getConfig().iota.expressLimit }), // accept anything JSON.parse accepts. checkMandatoryParams(false), parseData, addTimestamp, @@ -708,7 +708,7 @@ function start(callback) { httpBindingServer.router.post( (config.getConfig().iota.defaultResource || constants.HTTP_MEASURE_PATH) + constants.HTTP_CONFIGURATION_PATH, - bodyParser.json({ strict: false }), // accept anything JSON.parse accepts. + bodyParser.json({ strict: false, limit: config.getConfig().iota.expressLimit }), // accept anything JSON.parse accepts. checkMandatoryParams(false), parseData, handleConfigurationRequest