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
ed5853e6
Commit
ed5853e6
authored
Mar 30, 2015
by
Andy Wilkinson
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch '1.2.x'
parents
fd22b578
c3571d41
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
41 additions
and
12 deletions
+41
-12
ServerProperties.java
...ingframework/boot/autoconfigure/web/ServerProperties.java
+11
-1
ServerPropertiesTests.java
...amework/boot/autoconfigure/web/ServerPropertiesTests.java
+30
-11
No files found.
spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/web/ServerProperties.java
View file @
ed5853e6
...
@@ -483,10 +483,20 @@ public class ServerProperties implements EmbeddedServletContainerCustomizer, Ord
...
@@ -483,10 +483,20 @@ public class ServerProperties implements EmbeddedServletContainerCustomizer, Ord
if
(
handler
instanceof
AbstractHttp11Protocol
)
{
if
(
handler
instanceof
AbstractHttp11Protocol
)
{
@SuppressWarnings
(
"rawtypes"
)
@SuppressWarnings
(
"rawtypes"
)
AbstractHttp11Protocol
protocol
=
(
AbstractHttp11Protocol
)
handler
;
AbstractHttp11Protocol
protocol
=
(
AbstractHttp11Protocol
)
handler
;
protocol
.
setCompression
(
Tomcat
.
this
.
compression
);
protocol
.
setCompression
(
coerceCompression
(
Tomcat
.
this
.
compression
)
);
protocol
.
setCompressableMimeTypes
(
Tomcat
.
this
.
compressableMimeTypes
);
protocol
.
setCompressableMimeTypes
(
Tomcat
.
this
.
compressableMimeTypes
);
}
}
}
}
private
String
coerceCompression
(
String
compression
)
{
if
(
Boolean
.
toString
(
true
).
equals
(
compression
))
{
return
"on"
;
}
else
if
(
Boolean
.
toString
(
false
).
equals
(
compression
))
{
return
"off"
;
}
return
compression
;
}
});
});
if
(
this
.
accessLogEnabled
)
{
if
(
this
.
accessLogEnabled
)
{
...
...
spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/web/ServerPropertiesTests.java
View file @
ed5853e6
...
@@ -31,6 +31,8 @@ import org.springframework.boot.context.embedded.ConfigurableEmbeddedServletCont
...
@@ -31,6 +31,8 @@ import org.springframework.boot.context.embedded.ConfigurableEmbeddedServletCont
import
org.springframework.boot.context.embedded.tomcat.TomcatEmbeddedServletContainer
;
import
org.springframework.boot.context.embedded.tomcat.TomcatEmbeddedServletContainer
;
import
org.springframework.boot.context.embedded.tomcat.TomcatEmbeddedServletContainerFactory
;
import
org.springframework.boot.context.embedded.tomcat.TomcatEmbeddedServletContainerFactory
;
import
static
org
.
hamcrest
.
Matchers
.
equalTo
;
import
static
org
.
hamcrest
.
Matchers
.
is
;
import
static
org
.
hamcrest
.
core
.
IsInstanceOf
.
instanceOf
;
import
static
org
.
hamcrest
.
core
.
IsInstanceOf
.
instanceOf
;
import
static
org
.
junit
.
Assert
.
assertEquals
;
import
static
org
.
junit
.
Assert
.
assertEquals
;
import
static
org
.
junit
.
Assert
.
assertFalse
;
import
static
org
.
junit
.
Assert
.
assertFalse
;
...
@@ -197,9 +199,26 @@ public class ServerPropertiesTests {
...
@@ -197,9 +199,26 @@ public class ServerPropertiesTests {
@Test
@Test
public
void
customTomcatCompression
()
throws
Exception
{
public
void
customTomcatCompression
()
throws
Exception
{
assertThat
(
"on"
,
is
(
equalTo
(
configureCompression
(
"on"
))));
}
@Test
public
void
disableTomcatCompressionWithYaml
()
throws
Exception
{
// YAML interprets "off" as false, check that it's mapped back to off
assertThat
(
"off"
,
is
(
equalTo
(
configureCompression
(
"false"
))));
}
@Test
public
void
enableTomcatCompressionWithYaml
()
throws
Exception
{
// YAML interprets "on" as true, check that it's mapped back to on
assertThat
(
"on"
,
is
(
equalTo
(
configureCompression
(
"true"
))));
}
@Test
public
void
customTomcatCompressableMimeTypes
()
throws
Exception
{
Map
<
String
,
String
>
map
=
new
HashMap
<
String
,
String
>();
Map
<
String
,
String
>
map
=
new
HashMap
<
String
,
String
>();
map
.
put
(
"server.port"
,
"0"
);
map
.
put
(
"server.port"
,
"0"
);
map
.
put
(
"server.tomcat.compress
ion"
,
"on
"
);
map
.
put
(
"server.tomcat.compress
ableMimeTypes"
,
"application/foo
"
);
bindProperties
(
map
);
bindProperties
(
map
);
TomcatEmbeddedServletContainerFactory
factory
=
new
TomcatEmbeddedServletContainerFactory
();
TomcatEmbeddedServletContainerFactory
factory
=
new
TomcatEmbeddedServletContainerFactory
();
...
@@ -211,18 +230,23 @@ public class ServerPropertiesTests {
...
@@ -211,18 +230,23 @@ public class ServerPropertiesTests {
try
{
try
{
AbstractHttp11Protocol
<?>
protocol
=
(
AbstractHttp11Protocol
<?>)
container
AbstractHttp11Protocol
<?>
protocol
=
(
AbstractHttp11Protocol
<?>)
container
.
getTomcat
().
getConnector
().
getProtocolHandler
();
.
getTomcat
().
getConnector
().
getProtocolHandler
();
assertEquals
(
"
on"
,
protocol
.
getCompression
());
assertEquals
(
"
application/foo"
,
protocol
.
getCompressableMimeTypes
());
}
}
finally
{
finally
{
container
.
stop
();
container
.
stop
();
}
}
}
}
@Test
private
void
bindProperties
(
Map
<
String
,
String
>
map
)
{
public
void
customTomcatCompressableMimeTypes
()
throws
Exception
{
new
RelaxedDataBinder
(
this
.
properties
,
"server"
).
bind
(
new
MutablePropertyValues
(
map
));
}
private
String
configureCompression
(
String
compression
)
{
Map
<
String
,
String
>
map
=
new
HashMap
<
String
,
String
>();
Map
<
String
,
String
>
map
=
new
HashMap
<
String
,
String
>();
map
.
put
(
"server.port"
,
"0"
);
map
.
put
(
"server.port"
,
"0"
);
map
.
put
(
"server.tomcat.compressableMimeTypes"
,
"application/foo"
);
// YAML interprets "on" as true
map
.
put
(
"server.tomcat.compression"
,
compression
);
bindProperties
(
map
);
bindProperties
(
map
);
TomcatEmbeddedServletContainerFactory
factory
=
new
TomcatEmbeddedServletContainerFactory
();
TomcatEmbeddedServletContainerFactory
factory
=
new
TomcatEmbeddedServletContainerFactory
();
...
@@ -234,16 +258,11 @@ public class ServerPropertiesTests {
...
@@ -234,16 +258,11 @@ public class ServerPropertiesTests {
try
{
try
{
AbstractHttp11Protocol
<?>
protocol
=
(
AbstractHttp11Protocol
<?>)
container
AbstractHttp11Protocol
<?>
protocol
=
(
AbstractHttp11Protocol
<?>)
container
.
getTomcat
().
getConnector
().
getProtocolHandler
();
.
getTomcat
().
getConnector
().
getProtocolHandler
();
assertEquals
(
"application/foo"
,
protocol
.
getCompressableMimeTypes
()
);
return
protocol
.
getCompression
(
);
}
}
finally
{
finally
{
container
.
stop
();
container
.
stop
();
}
}
}
}
private
void
bindProperties
(
Map
<
String
,
String
>
map
)
{
new
RelaxedDataBinder
(
this
.
properties
,
"server"
).
bind
(
new
MutablePropertyValues
(
map
));
}
}
}
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