@@ -75,6 +75,7 @@ const { tagConditionKeyAuth } = require('./apiUtils/authorization/tagConditionKe
7575const { isRequesterASessionUser } = require ( './apiUtils/authorization/permissionChecks' ) ;
7676const checkHttpHeadersSize = require ( './apiUtils/object/checkHttpHeadersSize' ) ;
7777const constants = require ( '../../constants' ) ;
78+ const { config } = require ( '../Config.js' ) ;
7879
7980const monitoringMap = policies . actionMaps . actionMonitoringMapS3 ;
8081
@@ -219,15 +220,15 @@ const api = {
219220 // issue 100 Continue to the client
220221 writeContinue ( request , response ) ;
221222
222- const defaultMaxPostLength = request . method === 'POST' ?
223+ const defaultMaxBodyLength = request . method === 'POST' ?
223224 constants . oneMegaBytes : constants . halfMegaBytes ;
224- const MAX_POST_LENGTH = constants . apisLengthLimits [ apiMethod ] || defaultMaxPostLength ;
225+ const MAX_BODY_LENGTH = config . apiBodySizeLimits [ apiMethod ] || defaultMaxBodyLength ;
225226 const post = [ ] ;
226- let postLength = 0 ;
227+ let bodyLength = 0 ;
227228 request . on ( 'data' , chunk => {
228- postLength += chunk . length ;
229+ bodyLength += chunk . length ;
229230 // Sanity check on post length
230- if ( postLength <= MAX_POST_LENGTH ) {
231+ if ( bodyLength <= MAX_BODY_LENGTH ) {
231232 post . push ( chunk ) ;
232233 }
233234 } ) ;
@@ -240,13 +241,13 @@ const api = {
240241 } ) ;
241242
242243 request . on ( 'end' , ( ) => {
243- if ( postLength > MAX_POST_LENGTH ) {
244+ if ( bodyLength > MAX_BODY_LENGTH ) {
244245 log . error ( 'body length is too long for request type' ,
245- { postLength } ) ;
246+ { bodyLength } ) ;
246247 return next ( errors . InvalidRequest ) ;
247248 }
248249 // Convert array of post buffers into one string
249- request . post = Buffer . concat ( post , postLength ) . toString ( ) ;
250+ request . post = Buffer . concat ( post , bodyLength ) . toString ( ) ;
250251 return next ( null , userInfo , authorizationResults , streamingV4Params , infos ) ;
251252 } ) ;
252253 return undefined ;
0 commit comments