Package org.jolokia.server.core.util
Class MimeTypeUtil
java.lang.Object
org.jolokia.server.core.util.MimeTypeUtil
Helper class for handling proper response mime types
- Since:
- 24.01.18
- Author:
- roland
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic StringgetResponseMimeType(String pRequestMimeType, String defaultMimeType, String pCallback) Extract the response mime type.static booleanisValidCallback(String pCallback) Check that a callback matches a javascript function name.
-
Constructor Details
-
MimeTypeUtil
public MimeTypeUtil()
-
-
Method Details
-
getResponseMimeType
public static String getResponseMimeType(String pRequestMimeType, String defaultMimeType, String pCallback) Extract the response mime type. This value is calculated for different situations:- If a callback is given and its valid, the mime type is "text/javascript"
- Otherwise:
- If a valid mimeType is given in the request ("text/plain", "application/json"), then this mimet type is returned
- If another mimeType is given, then "text/plain" is used
- If no mimeType is given then a given default mime type is used, but also sanitized as described above
- Parameters:
pRequestMimeType- the mimetype given in the requestdefaultMimeType- the default mime type to use if none is given in the requestpCallback- a callback given (can be null)
-
isValidCallback
Check that a callback matches a javascript function name. The argument must be not null- Parameters:
pCallback- callback to verify- Returns:
- true if valud, false otherwise
-