Class MimeTypeUtil

java.lang.Object
org.jolokia.server.core.util.MimeTypeUtil

public class MimeTypeUtil extends Object
Helper class for handling proper response mime types
Since:
24.01.18
Author:
roland
  • 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 request
      defaultMimeType - the default mime type to use if none is given in the request
      pCallback - a callback given (can be null)
    • isValidCallback

      public static boolean isValidCallback(String pCallback)
      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