Extract MimeType as a base class of MediaType
MimeType is available in core-spring and does not include support for quality parameters and media used in HTTP content negotiation. The MediaType sub-class in org.springframework.http adds q-parameters.
This commit is contained in:
@@ -26,6 +26,7 @@ import java.util.Set;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
|
||||
import org.springframework.http.InvalidMediaTypeException;
|
||||
import org.springframework.http.MediaType;
|
||||
import org.springframework.util.StringUtils;
|
||||
import org.springframework.web.HttpMediaTypeNotSupportedException;
|
||||
@@ -221,7 +222,7 @@ public final class ConsumesRequestCondition extends AbstractRequestCondition<Con
|
||||
MediaType.APPLICATION_OCTET_STREAM;
|
||||
return getMediaType().includes(contentType);
|
||||
}
|
||||
catch (IllegalArgumentException ex) {
|
||||
catch (InvalidMediaTypeException ex) {
|
||||
throw new HttpMediaTypeNotSupportedException(
|
||||
"Can't parse Content-Type [" + request.getContentType() + "]: " + ex.getMessage());
|
||||
}
|
||||
|
||||
@@ -24,9 +24,11 @@ import java.util.LinkedHashSet;
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.Set;
|
||||
|
||||
import javax.servlet.ServletException;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
|
||||
import org.springframework.http.InvalidMediaTypeException;
|
||||
import org.springframework.http.MediaType;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
import org.springframework.util.MultiValueMap;
|
||||
@@ -205,7 +207,7 @@ public abstract class RequestMappingInfoHandlerMapping extends AbstractHandlerMe
|
||||
try {
|
||||
contentType = MediaType.parseMediaType(request.getContentType());
|
||||
}
|
||||
catch (IllegalArgumentException ex) {
|
||||
catch (InvalidMediaTypeException ex) {
|
||||
throw new HttpMediaTypeNotSupportedException(ex.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user