HttpHeaderUtils { public static String getContentTypeFromContentTypeAndCharacterSetting(String rawContentType) { if (rawContentType.contains(";")) { return rawContentType.split(";")[0]; } else { return rawContentType; } }  static String getContentTypeFromContentTypeAndCharacterSetting(String rawContentType); static String getCharsetOfContentType(String rawContentType, String defaultEncoding); static String getCharsetOfContentTypeOrUtf8(String rawContentType);  }
@Test public void testGetContentTypeFromContentTypeAndCharacterSetting() { assertEquals("application/json", HttpHeaderUtils.getContentTypeFromContentTypeAndCharacterSetting("application/json; charset=utf-8")); assertEquals("application/json", HttpHeaderUtils.getContentTypeFromContentTypeAndCharacterSetting("application/json")); }