Improve default content type selection

Previously ContentNegotiationManager continued with the next
ContentNegotiationStrategy only if the current one returned an empty
list. Now it also does that if the current ContentNegotiationStrategy
returns "*/*". Since the absence of an Accept header and "*/*" have
the same meaning, this allows a default content type to be used in
either case.

Issue: SPR-10513
This commit is contained in:
Rossen Stoyanchev
2013-05-10 11:10:15 -04:00
parent 532a7a3a02
commit 4d005b6987
2 changed files with 11 additions and 2 deletions

View File

@@ -122,6 +122,12 @@ public class ContentNegotiationManagerFactoryBeanTests {
ContentNegotiationManager manager = this.factoryBean.getObject();
assertEquals(Arrays.asList(MediaType.APPLICATION_JSON), manager.resolveMediaTypes(this.webRequest));
// SPR-10513
this.servletRequest.addHeader("Accept", MediaType.ALL_VALUE);
assertEquals(Arrays.asList(MediaType.APPLICATION_JSON), manager.resolveMediaTypes(this.webRequest));
}
}