@@ -180,10 +180,7 @@ public String body(String charset) throws IOException {
180180
181181 @ Override
182182 public InputStream bodyAsStream () throws IOException {
183- if (_request .getContentLengthLong () > ServerProps .request_maxBodySize ) {
184- //可兼容不同框架的情况
185- throw new StatusException ("Request Entity Too Large: " + _request .getContentLengthLong (), 413 );
186- }
183+ assertMaxBodySize ();
187184
188185 return _request .getInputStream ();
189186 }
@@ -204,17 +201,22 @@ public MultiMap<String> paramMap() {
204201 */
205202 private void paramsMapInit () {
206203 if (_paramMap == null ) {
207- _paramMap = new MultiMap <String >();
204+ _paramMap = new MultiMap <>();
208205
209206 try {
210- //编码窗体预处理
207+ if (isFormUrlencoded ()) {
208+ assertMaxBodySize ();
209+ }
210+
211+ //x-www-form-urlencoded(for put, delete ..)
211212 DecodeUtils .decodeFormUrlencoded (this );
212213
213- //多分段处理
214+ //try form-data
214215 if (autoMultipart ()) {
215216 loadMultipartFormData ();
216217 }
217218
219+ //queryString and x-www-form-urlencoded(for post)
218220 for (Map .Entry <String , String []> kv : _request .getParameterMap ().entrySet ()) {
219221 String name = ServerProps .urlDecode (kv .getKey ());
220222
@@ -226,6 +228,16 @@ private void paramsMapInit() {
226228 }
227229 }
228230
231+ /**
232+ * @since 3.6
233+ */
234+ protected void assertMaxBodySize () {
235+ if (_request .getContentLengthLong () > ServerProps .request_maxBodySize ) {
236+ //可兼容不同框架的情况
237+ throw new StatusException ("Request Entity Too Large: " + _request .getContentLengthLong (), 413 );
238+ }
239+ }
240+
229241 @ Override
230242 public MultiMap <UploadedFile > fileMap () {
231243 if (isMultipartFormData ()) {
@@ -415,7 +427,7 @@ private void sendHeaders() throws IOException {
415427
416428 ///////////////////////
417429 // for async
418- ///////////////////////
430+ /// ////////////////////
419431
420432 protected final AsyncContextState asyncState = new AsyncContextState ();
421433 private AsyncContext asyncContext ;
0 commit comments