Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Sign in / Register
Toggle navigation
S
spring-boot
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
DEMO
spring-boot
Commits
e7b5d956
Commit
e7b5d956
authored
Aug 12, 2018
by
Stephane Nicoll
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Adapt ServerProperties with a default size to DataSize
See gh-13974
parent
6734e112
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
15 additions
and
10 deletions
+15
-10
ServerProperties.java
...ingframework/boot/autoconfigure/web/ServerProperties.java
+5
-4
TomcatWebServerFactoryCustomizer.java
...figure/web/embedded/TomcatWebServerFactoryCustomizer.java
+3
-1
TomcatWebServerFactoryCustomizerTests.java
...e/web/embedded/TomcatWebServerFactoryCustomizerTests.java
+6
-4
appendix-application-properties.adoc
...cs/src/main/asciidoc/appendix-application-properties.adoc
+1
-1
No files found.
spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/web/ServerProperties.java
View file @
e7b5d956
...
...
@@ -37,6 +37,7 @@ import org.springframework.boot.web.server.Ssl;
import
org.springframework.boot.web.servlet.server.Jsp
;
import
org.springframework.boot.web.servlet.server.Session
;
import
org.springframework.util.StringUtils
;
import
org.springframework.util.unit.DataSize
;
/**
* {@link ConfigurationProperties} for a web server (e.g. port and path settings).
...
...
@@ -330,9 +331,9 @@ public class ServerProperties {
private
int
maxHttpHeaderSize
=
0
;
/**
* Maximum amount of request body
bytes
to swallow.
* Maximum amount of request body to swallow.
*/
private
int
maxSwallowSize
=
2097152
;
private
DataSize
maxSwallowSize
=
DataSize
.
ofMegaBytes
(
2
)
;
/**
* Whether requests to the context root should be redirected by appending a / to
...
...
@@ -496,11 +497,11 @@ public class ServerProperties {
return
this
.
maxHttpHeaderSize
;
}
public
int
getMaxSwallowSize
()
{
public
DataSize
getMaxSwallowSize
()
{
return
this
.
maxSwallowSize
;
}
public
void
setMaxSwallowSize
(
int
maxSwallowSize
)
{
public
void
setMaxSwallowSize
(
DataSize
maxSwallowSize
)
{
this
.
maxSwallowSize
=
maxSwallowSize
;
}
...
...
spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/web/embedded/TomcatWebServerFactoryCustomizer.java
View file @
e7b5d956
...
...
@@ -37,6 +37,7 @@ import org.springframework.boot.web.server.WebServerFactoryCustomizer;
import
org.springframework.core.Ordered
;
import
org.springframework.core.env.Environment
;
import
org.springframework.util.StringUtils
;
import
org.springframework.util.unit.DataSize
;
/**
* Customization for Tomcat-specific features common for both Servlet and Reactive
...
...
@@ -86,7 +87,8 @@ public class TomcatWebServerFactoryCustomizer implements
propertyMapper
.
from
(()
->
determineMaxHttpHeaderSize
()).
when
(
this
::
isPositive
)
.
to
((
maxHttpHeaderSize
)
->
customizeMaxHttpHeaderSize
(
factory
,
maxHttpHeaderSize
));
propertyMapper
.
from
(
tomcatProperties:
:
getMaxSwallowSize
)
propertyMapper
.
from
(
tomcatProperties:
:
getMaxSwallowSize
).
whenNonNull
()
.
asInt
(
DataSize:
:
toBytes
)
.
to
((
maxSwallowSize
)
->
customizeMaxSwallowSize
(
factory
,
maxSwallowSize
));
propertyMapper
.
from
(
tomcatProperties:
:
getMaxHttpPostSize
)
.
when
((
maxHttpPostSize
)
->
maxHttpPostSize
!=
0
)
...
...
spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/web/embedded/TomcatWebServerFactoryCustomizerTests.java
View file @
e7b5d956
...
...
@@ -41,6 +41,7 @@ import org.springframework.boot.web.embedded.tomcat.TomcatWebServer;
import
org.springframework.mock.env.MockEnvironment
;
import
org.springframework.test.context.support.TestPropertySourceUtils
;
import
org.springframework.test.util.ReflectionTestUtils
;
import
org.springframework.util.unit.DataSize
;
import
static
org
.
assertj
.
core
.
api
.
Assertions
.
assertThat
;
...
...
@@ -74,8 +75,9 @@ public class TomcatWebServerFactoryCustomizerTests {
public
void
defaultsAreConsistent
()
{
customizeAndRunServer
((
server
)
->
{
assertThat
(((
AbstractHttp11Protocol
<?>)
server
.
getTomcat
().
getConnector
()
.
getProtocolHandler
()).
getMaxSwallowSize
()).
isEqualTo
(
this
.
serverProperties
.
getTomcat
().
getMaxSwallowSize
());
.
getProtocolHandler
()).
getMaxSwallowSize
())
.
isEqualTo
(
this
.
serverProperties
.
getTomcat
()
.
getMaxSwallowSize
().
toBytes
());
});
}
...
...
@@ -121,10 +123,10 @@ public class TomcatWebServerFactoryCustomizerTests {
@Test
public
void
customMaxSwallowSize
()
{
bind
(
"server.tomcat.max-swallow-size=10"
);
bind
(
"server.tomcat.max-swallow-size=10
MB
"
);
customizeAndRunServer
((
server
)
->
assertThat
(((
AbstractHttp11Protocol
<?>)
server
.
getTomcat
().
getConnector
().
getProtocolHandler
()).
getMaxSwallowSize
())
.
isEqualTo
(
10
));
.
isEqualTo
(
DataSize
.
ofMegaBytes
(
10
).
toBytes
()
));
}
@Test
...
...
spring-boot-project/spring-boot-docs/src/main/asciidoc/appendix-application-properties.adoc
View file @
e7b5d956
...
...
@@ -260,7 +260,7 @@ content into your application. Rather, pick only the properties that you need.
server.tomcat.max-connections=0 # Maximum number of connections that the server accepts and processes at any given time.
server.tomcat.max-http-header-size=0 # Maximum size, in bytes, of the HTTP message header.
server.tomcat.max-http-post-size=0 # Maximum size, in bytes, of the HTTP post content.
server.tomcat.max-swallow-size=2
097152 # Maximum amount of request body bytes
to swallow.
server.tomcat.max-swallow-size=2
MB # Maximum amount of request body
to swallow.
server.tomcat.max-threads=0 # Maximum number of worker threads.
server.tomcat.min-spare-threads=0 # Minimum number of worker threads.
server.tomcat.port-header=X-Forwarded-Port # Name of the HTTP header used to override the original port value.
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment