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
e39e125a
Commit
e39e125a
authored
Apr 23, 2018
by
Brian Clozel
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch '2.0.x'
parents
50d73285
e3e404f9
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
19 additions
and
1 deletion
+19
-1
WebMvcAutoConfiguration.java
...ot/autoconfigure/web/servlet/WebMvcAutoConfiguration.java
+1
-1
WebMvcAutoConfigurationTests.java
...toconfigure/web/servlet/WebMvcAutoConfigurationTests.java
+18
-0
No files found.
spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/web/servlet/WebMvcAutoConfiguration.java
View file @
e39e125a
...
@@ -653,7 +653,7 @@ public class WebMvcAutoConfiguration {
...
@@ -653,7 +653,7 @@ public class WebMvcAutoConfiguration {
Object
skip
=
webRequest
.
getAttribute
(
SKIP_ATTRIBUTE
,
Object
skip
=
webRequest
.
getAttribute
(
SKIP_ATTRIBUTE
,
RequestAttributes
.
SCOPE_REQUEST
);
RequestAttributes
.
SCOPE_REQUEST
);
if
(
skip
!=
null
&&
Boolean
.
parseBoolean
(
skip
.
toString
()))
{
if
(
skip
!=
null
&&
Boolean
.
parseBoolean
(
skip
.
toString
()))
{
return
Collections
.
emptyList
()
;
return
MEDIA_TYPE_ALL_LIST
;
}
}
return
this
.
delegate
.
resolveMediaTypes
(
webRequest
);
return
this
.
delegate
.
resolveMediaTypes
(
webRequest
);
}
}
...
...
spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/web/servlet/WebMvcAutoConfigurationTests.java
View file @
e39e125a
...
@@ -55,6 +55,7 @@ import org.springframework.core.io.Resource;
...
@@ -55,6 +55,7 @@ import org.springframework.core.io.Resource;
import
org.springframework.format.support.FormattingConversionService
;
import
org.springframework.format.support.FormattingConversionService
;
import
org.springframework.http.CacheControl
;
import
org.springframework.http.CacheControl
;
import
org.springframework.http.HttpHeaders
;
import
org.springframework.http.HttpHeaders
;
import
org.springframework.http.MediaType
;
import
org.springframework.http.converter.HttpMessageConverter
;
import
org.springframework.http.converter.HttpMessageConverter
;
import
org.springframework.mock.web.MockHttpServletRequest
;
import
org.springframework.mock.web.MockHttpServletRequest
;
import
org.springframework.test.util.ReflectionTestUtils
;
import
org.springframework.test.util.ReflectionTestUtils
;
...
@@ -62,8 +63,11 @@ import org.springframework.util.StringUtils;
...
@@ -62,8 +63,11 @@ import org.springframework.util.StringUtils;
import
org.springframework.validation.Validator
;
import
org.springframework.validation.Validator
;
import
org.springframework.validation.beanvalidation.LocalValidatorFactoryBean
;
import
org.springframework.validation.beanvalidation.LocalValidatorFactoryBean
;
import
org.springframework.web.accept.ContentNegotiationManager
;
import
org.springframework.web.accept.ContentNegotiationManager
;
import
org.springframework.web.accept.ContentNegotiationStrategy
;
import
org.springframework.web.accept.ParameterContentNegotiationStrategy
;
import
org.springframework.web.accept.ParameterContentNegotiationStrategy
;
import
org.springframework.web.accept.PathExtensionContentNegotiationStrategy
;
import
org.springframework.web.bind.support.ConfigurableWebBindingInitializer
;
import
org.springframework.web.bind.support.ConfigurableWebBindingInitializer
;
import
org.springframework.web.context.request.ServletWebRequest
;
import
org.springframework.web.filter.HttpPutFormContentFilter
;
import
org.springframework.web.filter.HttpPutFormContentFilter
;
import
org.springframework.web.servlet.HandlerAdapter
;
import
org.springframework.web.servlet.HandlerAdapter
;
import
org.springframework.web.servlet.HandlerExceptionResolver
;
import
org.springframework.web.servlet.HandlerExceptionResolver
;
...
@@ -822,6 +826,20 @@ public class WebMvcAutoConfigurationTests {
...
@@ -822,6 +826,20 @@ public class WebMvcAutoConfigurationTests {
});
});
}
}
@Test
public
void
contentNegotiationStrategySkipsPathExtension
()
throws
Exception
{
ContentNegotiationStrategy
delegate
=
mock
(
ContentNegotiationStrategy
.
class
);
ContentNegotiationStrategy
strategy
=
new
WebMvcAutoConfiguration
.
OptionalPathExtensionContentNegotiationStrategy
(
delegate
);
MockHttpServletRequest
request
=
new
MockHttpServletRequest
();
request
.
setAttribute
(
PathExtensionContentNegotiationStrategy
.
class
.
getName
()
+
".SKIP"
,
Boolean
.
TRUE
);
ServletWebRequest
webRequest
=
new
ServletWebRequest
(
request
);
List
<
MediaType
>
mediaTypes
=
strategy
.
resolveMediaTypes
(
webRequest
);
assertThat
(
mediaTypes
).
containsOnly
(
MediaType
.
ALL
);
}
private
void
assertCacheControl
(
AssertableWebApplicationContext
context
)
{
private
void
assertCacheControl
(
AssertableWebApplicationContext
context
)
{
Map
<
String
,
Object
>
handlerMap
=
getHandlerMap
(
Map
<
String
,
Object
>
handlerMap
=
getHandlerMap
(
context
.
getBean
(
"resourceHandlerMapping"
,
HandlerMapping
.
class
));
context
.
getBean
(
"resourceHandlerMapping"
,
HandlerMapping
.
class
));
...
...
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