Expand range of whitelisted extensions by media type
This commit expands the range of whitelisted extensions by checking if an extension can be resolved to image/*, audo/*, video/*, as well as any content type that ends with +xml. Issue: SPR-13643
This commit is contained in:
@@ -60,7 +60,17 @@ public abstract class AbstractMappingContentNegotiationStrategy
|
||||
public List<MediaType> resolveMediaTypes(NativeWebRequest webRequest)
|
||||
throws HttpMediaTypeNotAcceptableException {
|
||||
|
||||
String key = getMediaTypeKey(webRequest);
|
||||
return resolveMediaTypeKey(webRequest, getMediaTypeKey(webRequest));
|
||||
}
|
||||
|
||||
/**
|
||||
* An alternative to {@link #resolveMediaTypes(NativeWebRequest)} that accepts
|
||||
* an already extracted key.
|
||||
* @since 3.2.16
|
||||
*/
|
||||
public List<MediaType> resolveMediaTypeKey(NativeWebRequest webRequest, String key)
|
||||
throws HttpMediaTypeNotAcceptableException {
|
||||
|
||||
if (StringUtils.hasText(key)) {
|
||||
MediaType mediaType = lookupMediaType(key);
|
||||
if (mediaType != null) {
|
||||
|
||||
@@ -88,6 +88,14 @@ public class ContentNegotiationManager implements ContentNegotiationStrategy,
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Return the configured content negotiation strategies.
|
||||
* @since 3.2.16
|
||||
*/
|
||||
public List<ContentNegotiationStrategy> getStrategies() {
|
||||
return this.strategies;
|
||||
}
|
||||
|
||||
/**
|
||||
* Register more {@code MediaTypeFileExtensionResolver} instances in addition
|
||||
* to those detected at construction.
|
||||
|
||||
Reference in New Issue
Block a user