HttpUtils { public static Map<String, String> parseContentTypeParams(String mimeType) { List<String> items = StringUtils.split(mimeType, ';', false); int count = items.size(); if (count <= 1) { return null; } Map<String, String> map = new LinkedHashMap(count - 1); for (int i = 1; i < count; i++) { String item = items.get(i); int pos = item.indexOf('='); if (pos == -1) { continue; } String key = item.substring(0, pos).trim(); String val = item.substring(pos + 1).trim(); map.put(key, val); } return map; } 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 testParseContentTypeParams() { Map<String, String> map = HttpUtils.parseContentTypeParams("application/json"); assertNull(map); map = HttpUtils.parseContentTypeParams("application/json; charset=UTF-8"); Match.equals(map, "{ charset: 'UTF-8' }"); map = HttpUtils.parseContentTypeParams("application/json; charset = UTF-8 "); Match.equals(map, "{ charset: 'UTF-8' }"); map = HttpUtils.parseContentTypeParams("application/json; charset=UTF-8; version=1.2.3"); Match.equals(map, "{ charset: 'UTF-8', version: '1.2.3' }"); map = HttpUtils.parseContentTypeParams("application/json; charset = UTF-8 ; version=1.2.3"); Match.equals(map, "{ charset: 'UTF-8', version: '1.2.3' }"); map = HttpUtils.parseContentTypeParams("application/vnd.app.test+json;ton-version=1"); Match.equals(map, "{ 'ton-version': '1' }"); }