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
f260cd9a
Commit
f260cd9a
authored
Nov 25, 2016
by
Stephane Nicoll
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch '1.5.x'
parents
e0d9352e
0befc310
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
88 additions
and
10 deletions
+88
-10
ServerProperties.java
...ingframework/boot/autoconfigure/web/ServerProperties.java
+53
-8
ServerPropertiesTests.java
...amework/boot/autoconfigure/web/ServerPropertiesTests.java
+32
-1
appendix-application-properties.adoc
...cs/src/main/asciidoc/appendix-application-properties.adoc
+3
-1
No files found.
spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/web/ServerProperties.java
View file @
f260cd9a
...
@@ -362,12 +362,18 @@ public class ServerProperties
...
@@ -362,12 +362,18 @@ public class ServerProperties
this
.
maxHttpHeaderSize
=
maxHttpHeaderSize
;
this
.
maxHttpHeaderSize
=
maxHttpHeaderSize
;
}
}
@Deprecated
@DeprecatedConfigurationProperty
(
reason
=
"Use dedicated property for each container."
)
public
int
getMaxHttpPostSize
()
{
public
int
getMaxHttpPostSize
()
{
return
this
.
maxHttpPostSize
;
return
this
.
maxHttpPostSize
;
}
}
@Deprecated
public
void
setMaxHttpPostSize
(
int
maxHttpPostSize
)
{
public
void
setMaxHttpPostSize
(
int
maxHttpPostSize
)
{
this
.
maxHttpPostSize
=
maxHttpPostSize
;
this
.
maxHttpPostSize
=
maxHttpPostSize
;
this
.
jetty
.
setMaxHttpPostSize
(
maxHttpPostSize
);
this
.
tomcat
.
setMaxHttpPostSize
(
maxHttpPostSize
);
this
.
undertow
.
setMaxHttpPostSize
(
maxHttpPostSize
);
}
}
protected
final
boolean
getOrDeduceUseForwardHeaders
()
{
protected
final
boolean
getOrDeduceUseForwardHeaders
()
{
...
@@ -645,6 +651,11 @@ public class ServerProperties
...
@@ -645,6 +651,11 @@ public class ServerProperties
*/
*/
private
int
minSpareThreads
=
0
;
// Minimum spare threads in protocol handler
private
int
minSpareThreads
=
0
;
// Minimum spare threads in protocol handler
/**
* Maximum size in bytes of the HTTP post content.
*/
private
int
maxHttpPostSize
=
0
;
// bytes
/**
/**
* Maximum size in bytes of the HTTP message header.
* Maximum size in bytes of the HTTP message header.
*/
*/
...
@@ -697,6 +708,14 @@ public class ServerProperties
...
@@ -697,6 +708,14 @@ public class ServerProperties
this
.
minSpareThreads
=
minSpareThreads
;
this
.
minSpareThreads
=
minSpareThreads
;
}
}
public
int
getMaxHttpPostSize
()
{
return
this
.
maxHttpPostSize
;
}
public
void
setMaxHttpPostSize
(
int
maxHttpPostSize
)
{
this
.
maxHttpPostSize
=
maxHttpPostSize
;
}
public
Accesslog
getAccesslog
()
{
public
Accesslog
getAccesslog
()
{
return
this
.
accesslog
;
return
this
.
accesslog
;
}
}
...
@@ -815,8 +834,8 @@ public class ServerProperties
...
@@ -815,8 +834,8 @@ public class ServerProperties
if
(
maxHttpHeaderSize
>
0
)
{
if
(
maxHttpHeaderSize
>
0
)
{
customizeMaxHttpHeaderSize
(
factory
,
maxHttpHeaderSize
);
customizeMaxHttpHeaderSize
(
factory
,
maxHttpHeaderSize
);
}
}
if
(
serverProperties
.
getMaxHttpPostSize
()
>
0
)
{
if
(
this
.
maxHttpPostSize
>
0
)
{
customizeMaxHttpPostSize
(
factory
,
serverProperties
.
getMaxHttpPostSize
()
);
customizeMaxHttpPostSize
(
factory
,
this
.
maxHttpPostSize
);
}
}
if
(
this
.
accesslog
.
enabled
)
{
if
(
this
.
accesslog
.
enabled
)
{
customizeAccessLog
(
factory
);
customizeAccessLog
(
factory
);
...
@@ -1116,6 +1135,11 @@ public class ServerProperties
...
@@ -1116,6 +1135,11 @@ public class ServerProperties
public
static
class
Jetty
{
public
static
class
Jetty
{
/**
* Maximum size in bytes of the HTTP post or put content.
*/
private
int
maxHttpPostSize
=
0
;
// bytes
/**
/**
* Number of acceptor threads to use.
* Number of acceptor threads to use.
*/
*/
...
@@ -1126,6 +1150,14 @@ public class ServerProperties
...
@@ -1126,6 +1150,14 @@ public class ServerProperties
*/
*/
private
Integer
selectors
;
private
Integer
selectors
;
public
int
getMaxHttpPostSize
()
{
return
this
.
maxHttpPostSize
;
}
public
void
setMaxHttpPostSize
(
int
maxHttpPostSize
)
{
this
.
maxHttpPostSize
=
maxHttpPostSize
;
}
public
Integer
getAcceptors
()
{
public
Integer
getAcceptors
()
{
return
this
.
acceptors
;
return
this
.
acceptors
;
}
}
...
@@ -1155,8 +1187,8 @@ public class ServerProperties
...
@@ -1155,8 +1187,8 @@ public class ServerProperties
customizeMaxHttpHeaderSize
(
factory
,
customizeMaxHttpHeaderSize
(
factory
,
serverProperties
.
getMaxHttpHeaderSize
());
serverProperties
.
getMaxHttpHeaderSize
());
}
}
if
(
serverProperties
.
getMaxHttpPostSize
()
>
0
)
{
if
(
this
.
maxHttpPostSize
>
0
)
{
customizeMaxHttpPostSize
(
factory
,
serverProperties
.
getMaxHttpPostSize
()
);
customizeMaxHttpPostSize
(
factory
,
this
.
maxHttpPostSize
);
}
}
if
(
serverProperties
.
getConnectionTimeout
()
!=
null
)
{
if
(
serverProperties
.
getConnectionTimeout
()
!=
null
)
{
...
@@ -1266,6 +1298,11 @@ public class ServerProperties
...
@@ -1266,6 +1298,11 @@ public class ServerProperties
public
static
class
Undertow
{
public
static
class
Undertow
{
/**
* Maximum size in bytes of the HTTP post content.
*/
private
long
maxHttpPostSize
=
0
;
// bytes
/**
/**
* Size of each buffer in bytes.
* Size of each buffer in bytes.
*/
*/
...
@@ -1294,6 +1331,14 @@ public class ServerProperties
...
@@ -1294,6 +1331,14 @@ public class ServerProperties
private
final
Accesslog
accesslog
=
new
Accesslog
();
private
final
Accesslog
accesslog
=
new
Accesslog
();
public
long
getMaxHttpPostSize
()
{
return
this
.
maxHttpPostSize
;
}
public
void
setMaxHttpPostSize
(
long
maxHttpPostSize
)
{
this
.
maxHttpPostSize
=
maxHttpPostSize
;
}
public
Integer
getBufferSize
()
{
public
Integer
getBufferSize
()
{
return
this
.
bufferSize
;
return
this
.
bufferSize
;
}
}
...
@@ -1366,8 +1411,8 @@ public class ServerProperties
...
@@ -1366,8 +1411,8 @@ public class ServerProperties
customizeMaxHttpHeaderSize
(
factory
,
customizeMaxHttpHeaderSize
(
factory
,
serverProperties
.
getMaxHttpHeaderSize
());
serverProperties
.
getMaxHttpHeaderSize
());
}
}
if
(
serverProperties
.
getMaxHttpPostSize
()
>
0
)
{
if
(
this
.
maxHttpPostSize
>
0
)
{
customizeMaxHttpPostSize
(
factory
,
serverProperties
.
getMaxHttpPostSize
()
);
customizeMaxHttpPostSize
(
factory
,
this
.
maxHttpPostSize
);
}
}
if
(
serverProperties
.
getConnectionTimeout
()
!=
null
)
{
if
(
serverProperties
.
getConnectionTimeout
()
!=
null
)
{
...
@@ -1404,13 +1449,13 @@ public class ServerProperties
...
@@ -1404,13 +1449,13 @@ public class ServerProperties
private
void
customizeMaxHttpPostSize
(
private
void
customizeMaxHttpPostSize
(
UndertowEmbeddedServletContainerFactory
factory
,
UndertowEmbeddedServletContainerFactory
factory
,
final
int
maxHttpPostSize
)
{
final
long
maxHttpPostSize
)
{
factory
.
addBuilderCustomizers
(
new
UndertowBuilderCustomizer
()
{
factory
.
addBuilderCustomizers
(
new
UndertowBuilderCustomizer
()
{
@Override
@Override
public
void
customize
(
Builder
builder
)
{
public
void
customize
(
Builder
builder
)
{
builder
.
setServerOption
(
UndertowOptions
.
MAX_ENTITY_SIZE
,
builder
.
setServerOption
(
UndertowOptions
.
MAX_ENTITY_SIZE
,
(
long
)
maxHttpPostSize
);
maxHttpPostSize
);
}
}
});
});
...
...
spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/web/ServerPropertiesTests.java
View file @
f260cd9a
...
@@ -310,7 +310,9 @@ public class ServerPropertiesTests {
...
@@ -310,7 +310,9 @@ public class ServerPropertiesTests {
Map
<
String
,
String
>
map
=
new
HashMap
<
String
,
String
>();
Map
<
String
,
String
>
map
=
new
HashMap
<
String
,
String
>();
map
.
put
(
"server.maxHttpPostSize"
,
"9999"
);
map
.
put
(
"server.maxHttpPostSize"
,
"9999"
);
bindProperties
(
map
);
bindProperties
(
map
);
assertThat
(
this
.
properties
.
getMaxHttpPostSize
()).
isEqualTo
(
9999
);
assertThat
(
this
.
properties
.
getJetty
().
getMaxHttpPostSize
()).
isEqualTo
(
9999
);
assertThat
(
this
.
properties
.
getTomcat
().
getMaxHttpPostSize
()).
isEqualTo
(
9999
);
assertThat
(
this
.
properties
.
getUndertow
().
getMaxHttpPostSize
()).
isEqualTo
(
9999
);
}
}
@Test
@Test
...
@@ -476,6 +478,35 @@ public class ServerPropertiesTests {
...
@@ -476,6 +478,35 @@ public class ServerPropertiesTests {
.
getProtocolHandler
()).
getMaxConnections
()).
isEqualTo
(
5
);
.
getProtocolHandler
()).
getMaxConnections
()).
isEqualTo
(
5
);
}
}
@Test
public
void
customTomcatMaxHttpPostSize
()
{
Map
<
String
,
String
>
map
=
new
HashMap
<
String
,
String
>();
map
.
put
(
"server.tomcat.max-http-post-size"
,
"10000"
);
bindProperties
(
map
);
TomcatEmbeddedServletContainerFactory
container
=
new
TomcatEmbeddedServletContainerFactory
();
this
.
properties
.
customize
(
container
);
TomcatEmbeddedServletContainer
embeddedContainer
=
(
TomcatEmbeddedServletContainer
)
container
.
getEmbeddedServletContainer
();
assertThat
(
embeddedContainer
.
getTomcat
().
getConnector
().
getMaxPostSize
())
.
isEqualTo
(
10000
);
}
@Test
@Deprecated
public
void
customTomcatMaxHttpPostSizeWithDeprecatedProperty
()
{
Map
<
String
,
String
>
map
=
new
HashMap
<
String
,
String
>();
map
.
put
(
"server.max-http-post-size"
,
"2000"
);
bindProperties
(
map
);
TomcatEmbeddedServletContainerFactory
container
=
new
TomcatEmbeddedServletContainerFactory
();
this
.
properties
.
customize
(
container
);
TomcatEmbeddedServletContainer
embeddedContainer
=
(
TomcatEmbeddedServletContainer
)
container
.
getEmbeddedServletContainer
();
assertThat
(
embeddedContainer
.
getTomcat
().
getConnector
().
getMaxPostSize
())
.
isEqualTo
(
2000
);
}
@Test
@Test
public
void
customizeUndertowAccessLog
()
{
public
void
customizeUndertowAccessLog
()
{
Map
<
String
,
String
>
map
=
new
HashMap
<
String
,
String
>();
Map
<
String
,
String
>
map
=
new
HashMap
<
String
,
String
>();
...
...
spring-boot-docs/src/main/asciidoc/appendix-application-properties.adoc
View file @
f260cd9a
...
@@ -153,11 +153,11 @@ content into your application; rather pick only the properties that you need.
...
@@ -153,11 +153,11 @@ content into your application; rather pick only the properties that you need.
server.context-path= # Context path of the application.
server.context-path= # Context path of the application.
server.display-name=application # Display name of the application.
server.display-name=application # Display name of the application.
server.max-http-header-size=0 # Maximum size in bytes of the HTTP message header.
server.max-http-header-size=0 # Maximum size in bytes of the HTTP message header.
server.max-http-post-size=0 # Maximum size in bytes of the HTTP post content.
server.error.include-stacktrace=never # When to include a "stacktrace" attribute.
server.error.include-stacktrace=never # When to include a "stacktrace" attribute.
server.error.path=/error # Path of the error controller.
server.error.path=/error # Path of the error controller.
server.error.whitelabel.enabled=true # Enable the default error page displayed in browsers in case of a server error.
server.error.whitelabel.enabled=true # Enable the default error page displayed in browsers in case of a server error.
server.jetty.acceptors= # Number of acceptor threads to use.
server.jetty.acceptors= # Number of acceptor threads to use.
server.jetty.max-http-post-size=0 # Maximum size in bytes of the HTTP post or put content.
server.jetty.selectors= # Number of selector threads to use.
server.jetty.selectors= # Number of selector threads to use.
server.jsp-servlet.class-name=org.apache.jasper.servlet.JspServlet # The class name of the JSP servlet.
server.jsp-servlet.class-name=org.apache.jasper.servlet.JspServlet # The class name of the JSP servlet.
server.jsp-servlet.init-parameters.*= # Init parameters used to configure the JSP servlet
server.jsp-servlet.init-parameters.*= # Init parameters used to configure the JSP servlet
...
@@ -212,6 +212,7 @@ content into your application; rather pick only the properties that you need.
...
@@ -212,6 +212,7 @@ content into your application; rather pick only the properties that you need.
172\\.2[0-9]{1}\\.\\d{1,3}\\.\\d{1,3}|\\
172\\.2[0-9]{1}\\.\\d{1,3}\\.\\d{1,3}|\\
172\\.3[0-1]{1}\\.\\d{1,3}\\.\\d{1,3} # regular expression matching trusted IP addresses.
172\\.3[0-1]{1}\\.\\d{1,3}\\.\\d{1,3} # regular expression matching trusted IP addresses.
server.tomcat.max-connections= # Maximum number of connections that the server will accept and process at any given time.
server.tomcat.max-connections= # Maximum number of connections that the server will accept and process at any given time.
server.tomcat.max-http-post-size=0 # Maximum size in bytes of the HTTP post content.
server.tomcat.max-threads=0 # Maximum amount of worker threads.
server.tomcat.max-threads=0 # Maximum amount of worker threads.
server.tomcat.min-spare-threads=0 # Minimum amount of worker threads.
server.tomcat.min-spare-threads=0 # Minimum amount of worker threads.
server.tomcat.port-header=X-Forwarded-Port # Name of the HTTP header used to override the original port value.
server.tomcat.port-header=X-Forwarded-Port # Name of the HTTP header used to override the original port value.
...
@@ -230,6 +231,7 @@ content into your application; rather pick only the properties that you need.
...
@@ -230,6 +231,7 @@ content into your application; rather pick only the properties that you need.
server.undertow.buffers-per-region= # Number of buffer per region.
server.undertow.buffers-per-region= # Number of buffer per region.
server.undertow.direct-buffers= # Allocate buffers outside the Java heap.
server.undertow.direct-buffers= # Allocate buffers outside the Java heap.
server.undertow.io-threads= # Number of I/O threads to create for the worker.
server.undertow.io-threads= # Number of I/O threads to create for the worker.
server.undertow.max-http-post-size=0 # Maximum size in bytes of the HTTP post content.
server.undertow.worker-threads= # Number of worker threads.
server.undertow.worker-threads= # Number of worker threads.
# FREEMARKER ({sc-spring-boot-autoconfigure}/freemarker/FreeMarkerAutoConfiguration.{sc-ext}[FreeMarkerAutoConfiguration])
# FREEMARKER ({sc-spring-boot-autoconfigure}/freemarker/FreeMarkerAutoConfiguration.{sc-ext}[FreeMarkerAutoConfiguration])
...
...
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