Package org.opensearch.core.xcontent
Class MediaTypeRegistry
java.lang.Object
org.opensearch.core.xcontent.MediaTypeRegistry
Parses supported internet media types
- Opensearch.internal:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classA media type object that contains all the information provided on a Content-Type or Accept header -
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic XContentBuildercontentBuilder(MediaType type) Returns a binary content builder for the provided content type.static XContentBuildercontentBuilder(MediaType type, OutputStream outputStream) static MediaTypefromFormat(String format) static MediaTypefromMediaType(String mediaType) static MediaTypestatic MediaTypemediaTypeFromBytes(byte[] data, int offset, int length) Deprecated.the content type should not be guessed except for few cases where we effectively don't know the content type.parseMediaType(String headerValue) parsing media type that follows https://tools.ietf.org/html/rfc7231#section-3.1.1.1static MediaTypexContent(byte[] data) Deprecated.the content type should not be guessed except for few cases where we effectively don't know the content type.static MediaTypexContent(byte[] data, int offset, int length) Deprecated.the content type should not be guessed except for few cases where we effectively don't know the content type.static MediaTypexContent(CharSequence content) Deprecated.the content type should not be guessed except for few cases where we effectively don't know the content type.static MediaTypeDeprecated.the content type should not be guessed except for few cases where we effectively don't know the content type.static MediaTypexContentType(CharSequence content) Deprecated.the content type should not be guessed except for few cases where we effectively don't know the content type.static MediaTypexContentType(BytesReference bytes) Deprecated.the content type should not be guessed except for few cases where we effectively don't know the content type.
-
Field Details
-
GUESS_HEADER_LENGTH
public static final int GUESS_HEADER_LENGTH- See Also:
-
JSON
-
-
Constructor Details
-
MediaTypeRegistry
public MediaTypeRegistry()
-
-
Method Details
-
fromMediaType
-
fromFormat
-
contentBuilder
Returns a binary content builder for the provided content type.- Throws:
IOException
-
contentBuilder
public static XContentBuilder contentBuilder(MediaType type, OutputStream outputStream) throws IOException - Throws:
IOException
-
xContent
Deprecated.the content type should not be guessed except for few cases where we effectively don't know the content type. The REST layer should move to reading the Content-Type header instead. There are other places where auto-detection may be needed. This method is deprecated to prevent usages of it from spreading further without specific reasons.Guesses the content (type) based on the provided char sequence and returns the correspondingXContent -
xContent
Deprecated.the content type should not be guessed except for few cases where we effectively don't know the content type. The REST layer should move to reading the Content-Type header instead. There are other places where auto-detection may be needed. This method is deprecated to prevent usages of it from spreading further without specific reasons.Guesses the content type based on the provided bytes and returns the correspondingXContent -
xContent
Deprecated.the content type should not be guessed except for few cases where we effectively don't know the content type. The REST layer should move to reading the Content-Type header instead. There are other places where auto-detection may be needed. This method is deprecated to prevent usages of it from spreading further without specific reasons.Guesses the content (type) based on the provided char sequence and returns the correspondingXContent -
xContentType
Deprecated.the content type should not be guessed except for few cases where we effectively don't know the content type. The REST layer should move to reading the Content-Type header instead. There are other places where auto-detection may be needed. This method is deprecated to prevent usages of it from spreading further without specific reasons.Guesses the content type based on the provided char sequence. -
xContentType
Deprecated.the content type should not be guessed except for few cases where we effectively don't know the content type. The REST layer should move to reading the Content-Type header instead. There are other places where auto-detection may be needed. This method is deprecated to prevent usages of it from spreading further without specific reasons.Guesses the content type based on the provided input stream without consuming it.- Throws:
IOException
-
xContentType
Deprecated.the content type should not be guessed except for few cases where we effectively don't know the content type. The REST layer should move to reading the Content-Type header instead. There are other places where auto-detection may be needed. This method is deprecated to prevent usages of it from spreading further without specific reasons.Guesses the content type based on the provided bytes. -
mediaTypeFromBytes
Deprecated.the content type should not be guessed except for few cases where we effectively don't know the content type. The REST layer should move to reading the Content-Type header instead. There are other places where auto-detection may be needed. This method is deprecated to prevent usages of it from spreading further without specific reasons.Guesses the content type based on the provided bytes. -
parseMediaType
parsing media type that follows https://tools.ietf.org/html/rfc7231#section-3.1.1.1- Parameters:
headerValue- a header value from Accept or Content-Type- Returns:
- a parsed media-type
-
getDefaultMediaType
-