HttpUtils { public static Charset parseContentTypeCharset(String mimeType) { Map<String, String> map = parseContentTypeParams(mimeType); if (map == null) { return null; } String cs = map.get(CHARSET); if (cs == null) { return null; } return Charset.forName(cs); } private  HttpUtils(); static KeyStore getKeyStore(ScenarioContext context, String trustStoreFile, String password, String type); static boolean isPrintable(String mediaType); static Charset parseContentTypeCharset(String mimeType); static Map<String, String> parseContentTypeParams(String mimeType); static String getContentType(ScriptValue sv); static Map<String, Cookie> parseCookieHeaderString(String header); static String createCookieHeaderValue(Collection<Cookie> cookies); static Map<String, String> parseUriPattern(String pattern, String url); static final String normaliseUriPath(String uri); static List<Integer> calculatePathMatchScore(String path); static String generateMimeBoundaryMarker(); static String multiPartToString(List<MultiPartItem> items, String boundary); static final String HEADER_CONTENT_TYPE; static final String HEADER_CONTENT_LENGTH; static final String HEADER_ACCEPT; static final String HEADER_ALLOW; static final String HEADER_AC_ALLOW_ORIGIN; static final String HEADER_AC_ALLOW_METHODS; static final String HEADER_AC_REQUEST_HEADERS; static final String HEADER_AC_ALLOW_HEADERS; static final String CHARSET; static final Set<String> HTTP_METHODS; static final List<Integer> DEFAULT_PATH_SCORE; }
@Test public void testParseContentTypeCharset() { assertEquals(FileUtils.UTF8, HttpUtils.parseContentTypeCharset("application/json; charset=UTF-8")); assertEquals(FileUtils.UTF8, HttpUtils.parseContentTypeCharset("application/json; charset = UTF-8 ")); assertEquals(FileUtils.UTF8, HttpUtils.parseContentTypeCharset("application/json; charset=UTF-8; version=1.2.3")); assertEquals(FileUtils.UTF8, HttpUtils.parseContentTypeCharset("application/json; charset = UTF-8 ; version=1.2.3")); }