Package org.elasticsearch.xcontent
Class ParsedMediaType
java.lang.Object
org.elasticsearch.xcontent.ParsedMediaType
A raw result of parsing media types from Accept or Content-Type headers.
It follow parsing and validates as per rules defined in https://tools.ietf.org/html/rfc7231#section-3.1.1.1
Can be resolved to
MediaType
- See Also:
-
Method Summary
Modifier and TypeMethodDescriptionThe parsed mime type without the associated parameters.static ParsedMediaType
parseMediaType
(String headerValue) Parses a header value into it's parts.static ParsedMediaType
parseMediaType
(XContentType requestContentType, Map<String, String> parameters) responseContentTypeHeader
(Map<String, String> params) <T extends MediaType>
TtoMediaType
(MediaTypeRegistry<T> mediaTypeRegistry) Resolves this instance to a MediaType instance defined in given MediaTypeRegistry.toString()
-
Method Details
-
mediaTypeWithoutParameters
The parsed mime type without the associated parameters. Will always return lowercase. -
getParameters
-
parseMediaType
Parses a header value into it's parts. follows https://tools.ietf.org/html/rfc7231#section-3.1.1.1 but allows only single media type. Media ranges will be ignored (treated as not provided) Note: parsing can return null, but it will throw exceptions once https://github.com/elastic/elasticsearch/issues/63080 is done TODO Do not rely on nulls- Returns:
- a
ParsedMediaType
if the header could be parsed. - Throws:
IllegalArgumentException
- if the header is malformed
-
parseMediaType
public static ParsedMediaType parseMediaType(XContentType requestContentType, Map<String, String> parameters) -
toMediaType
Resolves this instance to a MediaType instance defined in given MediaTypeRegistry. Performs validation against parameters.- Parameters:
mediaTypeRegistry
- a registry where a mapping between a raw media type to an instance MediaType is defined- Returns:
- a MediaType instance or null if no media type could be found or if a known parameter do not passes validation
-
toString
-
responseContentTypeHeader
-
responseContentTypeHeader
-