GetParameterNamesResponse from CPEs with many parameters exceeds the default 56kb raw body limit. Add a 'raw' section in bodyparser config covering text/xml, application/xml and application/soap+xml with a 4mb limit to handle large TR-069 discovery responses.
94 lines
2.0 KiB
TypeScript
94 lines
2.0 KiB
TypeScript
import { defineConfig } from '@adonisjs/core/bodyparser'
|
|
|
|
const bodyParserConfig = defineConfig({
|
|
/**
|
|
* Parse request bodies for these HTTP methods.
|
|
* Keep this aligned with methods that receive payloads in your routes.
|
|
*/
|
|
allowedMethods: ['POST', 'PUT', 'PATCH', 'DELETE'],
|
|
|
|
/**
|
|
* Config for the "application/x-www-form-urlencoded"
|
|
* content-type parser.
|
|
*/
|
|
form: {
|
|
/**
|
|
* Normalize empty string values to null.
|
|
*/
|
|
convertEmptyStringsToNull: true,
|
|
|
|
/**
|
|
* Content types handled by the form parser.
|
|
*/
|
|
types: ['application/x-www-form-urlencoded'],
|
|
},
|
|
|
|
/**
|
|
* Config for the JSON parser.
|
|
*/
|
|
json: {
|
|
/**
|
|
* Normalize empty string values to null.
|
|
*/
|
|
convertEmptyStringsToNull: true,
|
|
|
|
/**
|
|
* Content types handled by the JSON parser.
|
|
*/
|
|
types: [
|
|
'application/json',
|
|
'application/json-patch+json',
|
|
'application/vnd.api+json',
|
|
'application/csp-report',
|
|
],
|
|
},
|
|
|
|
/**
|
|
* Config for the "multipart/form-data" content-type parser.
|
|
* File uploads are handled by the multipart parser.
|
|
*/
|
|
multipart: {
|
|
/**
|
|
* Automatically process uploaded files into the system tmp directory.
|
|
*/
|
|
autoProcess: true,
|
|
|
|
/**
|
|
* Normalize empty string values to null.
|
|
*/
|
|
convertEmptyStringsToNull: true,
|
|
|
|
/**
|
|
* Routes where multipart processing is handled manually.
|
|
*/
|
|
processManually: [],
|
|
|
|
/**
|
|
* Maximum accepted payload size for multipart requests.
|
|
*/
|
|
limit: '20mb',
|
|
|
|
/**
|
|
* Content types handled by the multipart parser.
|
|
*/
|
|
types: ['multipart/form-data'],
|
|
},
|
|
|
|
/**
|
|
* Config for raw/text body parsing.
|
|
* CWMP/TR-069 uses text/xml. A GetParameterNamesResponse can easily
|
|
* exceed the default 56kb limit on devices with many parameters.
|
|
*/
|
|
raw: {
|
|
limit: '4mb',
|
|
types: [
|
|
'text/xml',
|
|
'application/xml',
|
|
'application/soap+xml',
|
|
'text/plain',
|
|
],
|
|
},
|
|
})
|
|
|
|
export default bodyParserConfig
|