Commit 39c03fc 1 parent 32433e8 commit 39c03fc Copy full SHA for 39c03fc
File tree 4 files changed +48
-10
lines changed
spring-boot-project/spring-boot-autoconfigure/src
main/java/org/springframework/boot/autoconfigure/web
test/java/org/springframework/boot/autoconfigure/web
4 files changed +48
-10
lines changed Original file line number Diff line number Diff line change 73
73
* @author Florian Storz
74
74
* @author Michael Weidmann
75
75
* @author Lasse Wulff
76
+ * @author Yanming Zhou
76
77
* @since 1.0.0
77
78
*/
78
79
@ ConfigurationProperties (prefix = "server" , ignoreUnknownFields = true )
@@ -513,13 +514,11 @@ public static class Tomcat {
513
514
*/
514
515
private DataSize maxHttpResponseHeaderSize = DataSize .ofKilobytes (8 );
515
516
516
- public DataSize getMaxHttpFormPostSize () {
517
- return this .maxHttpFormPostSize ;
518
- }
519
-
520
- public void setMaxHttpFormPostSize (DataSize maxHttpFormPostSize ) {
521
- this .maxHttpFormPostSize = maxHttpFormPostSize ;
522
- }
517
+ /**
518
+ * Maximum number of parameters (GET plus POST) that will be automatically parsed
519
+ * by the container.
520
+ */
521
+ private Integer maxParameterCount ;
523
522
524
523
public Accesslog getAccesslog () {
525
524
return this .accesslog ;
@@ -669,6 +668,22 @@ public void setMaxHttpResponseHeaderSize(DataSize maxHttpResponseHeaderSize) {
669
668
this .maxHttpResponseHeaderSize = maxHttpResponseHeaderSize ;
670
669
}
671
670
671
+ public DataSize getMaxHttpFormPostSize () {
672
+ return this .maxHttpFormPostSize ;
673
+ }
674
+
675
+ public void setMaxHttpFormPostSize (DataSize maxHttpFormPostSize ) {
676
+ this .maxHttpFormPostSize = maxHttpFormPostSize ;
677
+ }
678
+
679
+ public Integer getMaxParameterCount () {
680
+ return this .maxParameterCount ;
681
+ }
682
+
683
+ public void setMaxParameterCount (Integer maxParameterCount ) {
684
+ this .maxParameterCount = maxParameterCount ;
685
+ }
686
+
672
687
/**
673
688
* Tomcat access log properties.
674
689
*/
Original file line number Diff line number Diff line change 62
62
* @author Parviz Rozikov
63
63
* @author Florian Storz
64
64
* @author Michael Weidmann
65
+ * @author Yanming Zhou
65
66
* @since 2.0.0
66
67
*/
67
68
public class TomcatWebServerFactoryCustomizer
@@ -119,6 +120,9 @@ public void customize(ConfigurableTomcatWebServerFactory factory) {
119
120
.asInt (DataSize ::toBytes )
120
121
.when ((maxHttpFormPostSize ) -> maxHttpFormPostSize != 0 )
121
122
.to ((maxHttpFormPostSize ) -> customizeMaxHttpFormPostSize (factory , maxHttpFormPostSize ));
123
+ map .from (properties ::getMaxParameterCount )
124
+ .whenNonNull ()
125
+ .to ((maxParameterCount ) -> customizeMaxParameterCount (factory , maxParameterCount ));
122
126
map .from (properties ::getAccesslog )
123
127
.when (ServerProperties .Tomcat .Accesslog ::isEnabled )
124
128
.to ((enabled ) -> customizeAccessLog (factory ));
@@ -292,6 +296,10 @@ private void customizeMaxHttpFormPostSize(ConfigurableTomcatWebServerFactory fac
292
296
factory .addConnectorCustomizers ((connector ) -> connector .setMaxPostSize (maxHttpFormPostSize ));
293
297
}
294
298
299
+ private void customizeMaxParameterCount (ConfigurableTomcatWebServerFactory factory , int maxParameterCount ) {
300
+ factory .addConnectorCustomizers ((connector ) -> connector .setMaxParameterCount (maxParameterCount ));
301
+ }
302
+
295
303
private void customizeAccessLog (ConfigurableTomcatWebServerFactory factory ) {
296
304
ServerProperties .Tomcat tomcatProperties = this .serverProperties .getTomcat ();
297
305
AccessLogValve valve = new AccessLogValve ();
Original file line number Diff line number Diff line change 69
69
* @author Chris Bono
70
70
* @author Parviz Rozikov
71
71
* @author Lasse Wulff
72
+ * @author Yanming Zhou
72
73
*/
73
74
@ DirtiesUrlFactories
74
75
class ServerPropertiesTests {
@@ -199,7 +200,7 @@ void testCustomizedMimeMapping() {
199
200
}
200
201
201
202
@ Test
202
- void testCustomizeUriEncoding () {
203
+ void testCustomizeTomcatUriEncoding () {
203
204
bind ("server.tomcat.uri-encoding" , "US-ASCII" );
204
205
assertThat (this .properties .getTomcat ().getUriEncoding ()).isEqualTo (StandardCharsets .US_ASCII );
205
206
}
@@ -235,17 +236,23 @@ void testCustomizeTomcatKeepAliveTimeoutWithInfinite() {
235
236
}
236
237
237
238
@ Test
238
- void customizeMaxKeepAliveRequests () {
239
+ void testCustomizeTomcatMaxKeepAliveRequests () {
239
240
bind ("server.tomcat.max-keep-alive-requests" , "200" );
240
241
assertThat (this .properties .getTomcat ().getMaxKeepAliveRequests ()).isEqualTo (200 );
241
242
}
242
243
243
244
@ Test
244
- void customizeMaxKeepAliveRequestsWithInfinite () {
245
+ void testCustomizeTomcatMaxKeepAliveRequestsWithInfinite () {
245
246
bind ("server.tomcat.max-keep-alive-requests" , "-1" );
246
247
assertThat (this .properties .getTomcat ().getMaxKeepAliveRequests ()).isEqualTo (-1 );
247
248
}
248
249
250
+ @ Test
251
+ void testCustomizeTomcatMaxParameterCount () {
252
+ bind ("server.tomcat.max-parameter-count" , "100" );
253
+ assertThat (this .properties .getTomcat ().getMaxParameterCount ()).isEqualTo (100 );
254
+ }
255
+
249
256
@ Test
250
257
void testCustomizeTomcatMinSpareThreads () {
251
258
bind ("server.tomcat.threads.min-spare" , "10" );
Original file line number Diff line number Diff line change 59
59
* @author Victor Mandujano
60
60
* @author Parviz Rozikov
61
61
* @author Moritz Halbritter
62
+ * @author Yanming Zhou
62
63
*/
63
64
class TomcatWebServerFactoryCustomizerTests {
64
65
@@ -194,6 +195,13 @@ void customMaxHttpRequestHeaderSize() {
194
195
.isEqualTo (DataSize .ofMegabytes (10 ).toBytes ()));
195
196
}
196
197
198
+ @ Test
199
+ void customMaxParameterCount () {
200
+ bind ("server.tomcat.max-parameter-count=100" );
201
+ customizeAndRunServer (
202
+ (server ) -> assertThat (server .getTomcat ().getConnector ().getMaxParameterCount ()).isEqualTo (100 ));
203
+ }
204
+
197
205
@ Test
198
206
void customMaxRequestHttpHeaderSizeIgnoredIfNegative () {
199
207
bind ("server.max-http-request-header-size=-1" );
You can’t perform that action at this time.
0 commit comments