Przeglądaj źródła

Make max JSON request size configurable and default to 8 MB

This is to allow multi-document updates, for example when creating a new
project from a zip file.
Eric Mc Sween 6 lat temu
rodzic
commit
e8f935d046

+ 1 - 1
services/document-updater/app.js

@@ -31,7 +31,7 @@ Metrics.event_loop.monitor(logger, 100)
 
 const app = express()
 app.use(Metrics.http.monitor(logger))
-app.use(bodyParser.json({ limit: Settings.max_doc_length + 64 * 1024 }))
+app.use(bodyParser.json({ limit: Settings.maxJsonRequestSize }))
 Metrics.injectMetricsRoute(app)
 
 DispatchManager.createAndStartDispatchers(Settings.dispatcherCount || 10)

+ 2 - 0
services/document-updater/config/settings.defaults.js

@@ -168,6 +168,8 @@ module.exports = {
   },
 
   max_doc_length: 2 * 1024 * 1024, // 2mb
+  maxJsonRequestSize:
+    parseInt(process.env.MAX_JSON_REQUEST_SIZE, 10) || 8 * 1024 * 1024,
 
   dispatcherCount: process.env.DISPATCHER_COUNT,
 

+ 1 - 2
services/document-updater/test/acceptance/js/SettingADocumentTests.js

@@ -230,8 +230,7 @@ describe('Setting a document', function () {
       })
       this.newLines = []
       while (
-        JSON.stringify(this.newLines).length <
-        Settings.max_doc_length + 64 * 1024
+        JSON.stringify(this.newLines).length <= Settings.maxJsonRequestSize
       ) {
         this.newLines.push('(a long line of text)'.repeat(10000))
       }