@Test void getCookies() { CurlParserUtil.getInstance().getCookies(curlLine).forEach((k,v) -> System.out.println(k + " : " + v)); }
public Map<String, String> getCookies(String curlLine) { Map<String, String> cookieMap = new HashMap<>(); StringBuilder cookiesString = new StringBuilder(); cookiesString.append(getHeaders(curlLine).get("Cookie")); cookiesString.append(getBCookiesString(curlLine)); if (StringUtil.isNotBlank(cookiesString.toString())) { String cookiesPattern = "([^; ]*=[^;]*)+"; List<String> cookieStringList = RegexUtil.getInstance().getMacthAllResult(cookiesPattern,cookiesString.toString()); cookieStringList.forEach(cookie -> { String[] cookiePairs = cookie.split("=", 2); if (cookiePairs.length == 2) { cookieMap.put(cookiePairs[0].trim(), URLDecoder.decode(cookiePairs[1].trim())); } }); } return cookieMap; }
CurlParserUtil { public Map<String, String> getCookies(String curlLine) { Map<String, String> cookieMap = new HashMap<>(); StringBuilder cookiesString = new StringBuilder(); cookiesString.append(getHeaders(curlLine).get("Cookie")); cookiesString.append(getBCookiesString(curlLine)); if (StringUtil.isNotBlank(cookiesString.toString())) { String cookiesPattern = "([^; ]*=[^;]*)+"; List<String> cookieStringList = RegexUtil.getInstance().getMacthAllResult(cookiesPattern,cookiesString.toString()); cookieStringList.forEach(cookie -> { String[] cookiePairs = cookie.split("=", 2); if (cookiePairs.length == 2) { cookieMap.put(cookiePairs[0].trim(), URLDecoder.decode(cookiePairs[1].trim())); } }); } return cookieMap; } }
CurlParserUtil { public Map<String, String> getCookies(String curlLine) { Map<String, String> cookieMap = new HashMap<>(); StringBuilder cookiesString = new StringBuilder(); cookiesString.append(getHeaders(curlLine).get("Cookie")); cookiesString.append(getBCookiesString(curlLine)); if (StringUtil.isNotBlank(cookiesString.toString())) { String cookiesPattern = "([^; ]*=[^;]*)+"; List<String> cookieStringList = RegexUtil.getInstance().getMacthAllResult(cookiesPattern,cookiesString.toString()); cookieStringList.forEach(cookie -> { String[] cookiePairs = cookie.split("=", 2); if (cookiePairs.length == 2) { cookieMap.put(cookiePairs[0].trim(), URLDecoder.decode(cookiePairs[1].trim())); } }); } return cookieMap; } private  CurlParserUtil(); }
CurlParserUtil { public Map<String, String> getCookies(String curlLine) { Map<String, String> cookieMap = new HashMap<>(); StringBuilder cookiesString = new StringBuilder(); cookiesString.append(getHeaders(curlLine).get("Cookie")); cookiesString.append(getBCookiesString(curlLine)); if (StringUtil.isNotBlank(cookiesString.toString())) { String cookiesPattern = "([^; ]*=[^;]*)+"; List<String> cookieStringList = RegexUtil.getInstance().getMacthAllResult(cookiesPattern,cookiesString.toString()); cookieStringList.forEach(cookie -> { String[] cookiePairs = cookie.split("=", 2); if (cookiePairs.length == 2) { cookieMap.put(cookiePairs[0].trim(), URLDecoder.decode(cookiePairs[1].trim())); } }); } return cookieMap; } private  CurlParserUtil(); static CurlParserUtil getInstance(); Map<String, String> getHeaders(String curlLine); Map<String, String> getCookies(String curlLine); String getMethod(String curlLine); String getUrl(String curlLine); String getBodyString(String curlLine); Map<String, String> getFormBody(String curlLine); }
CurlParserUtil { public Map<String, String> getCookies(String curlLine) { Map<String, String> cookieMap = new HashMap<>(); StringBuilder cookiesString = new StringBuilder(); cookiesString.append(getHeaders(curlLine).get("Cookie")); cookiesString.append(getBCookiesString(curlLine)); if (StringUtil.isNotBlank(cookiesString.toString())) { String cookiesPattern = "([^; ]*=[^;]*)+"; List<String> cookieStringList = RegexUtil.getInstance().getMacthAllResult(cookiesPattern,cookiesString.toString()); cookieStringList.forEach(cookie -> { String[] cookiePairs = cookie.split("=", 2); if (cookiePairs.length == 2) { cookieMap.put(cookiePairs[0].trim(), URLDecoder.decode(cookiePairs[1].trim())); } }); } return cookieMap; } private  CurlParserUtil(); static CurlParserUtil getInstance(); Map<String, String> getHeaders(String curlLine); Map<String, String> getCookies(String curlLine); String getMethod(String curlLine); String getUrl(String curlLine); String getBodyString(String curlLine); Map<String, String> getFormBody(String curlLine);  }