Update HttpHeaders.getAccept method
Some servlet containers (iPlanet) parse the Accept header and return
multiple values from request.getHeader("Accept"). The HttpHeaders
getAccept method has been updated to accommodate that hopefully
without causing any other issues.
The extra functionality is in effect only if we find only one
MediaType and there is more than one value for the 'Accept' header.
Issue: SPR-9655
This commit is contained in:
@@ -153,7 +153,15 @@ public class HttpHeaders implements MultiValueMap<String, String>, Serializable
|
||||
*/
|
||||
public List<MediaType> getAccept() {
|
||||
String value = getFirst(ACCEPT);
|
||||
return (value != null ? MediaType.parseMediaTypes(value) : Collections.<MediaType>emptyList());
|
||||
List<MediaType> result = (value != null) ? MediaType.parseMediaTypes(value) : Collections.<MediaType>emptyList();
|
||||
|
||||
// Some containers parse 'Accept' into multiple values
|
||||
if ((result.size() == 1) && (headers.get(ACCEPT).size() > 1)) {
|
||||
value = StringUtils.collectionToCommaDelimitedString(headers.get(ACCEPT));
|
||||
result = MediaType.parseMediaTypes(value);
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user