@Test void getFormBody() { CurlParserUtil.getInstance().getFormBody(curlLine).forEach((k,v) -> System.out.println(k + " : " + v)); }
public Map<String, String> getFormBody(String curlLine) { Map<String, String> formMap = new HashMap<>(); String formBodyString = getBodyString(curlLine); String formDataPattern = "([^=&]+=[^&']*)+"; int formDataIndex = 1; List<String> formStringList = RegexUtil.getInstance().getMacthAllResult(formDataPattern, formBodyString, formDataIndex); formStringList.forEach(formString -> { String[] form = formString.split("=",2); if (form.length==2) { formMap.put(form[0].trim(),form[1].trim()); } }); return formMap; }
CurlParserUtil { public Map<String, String> getFormBody(String curlLine) { Map<String, String> formMap = new HashMap<>(); String formBodyString = getBodyString(curlLine); String formDataPattern = "([^=&]+=[^&']*)+"; int formDataIndex = 1; List<String> formStringList = RegexUtil.getInstance().getMacthAllResult(formDataPattern, formBodyString, formDataIndex); formStringList.forEach(formString -> { String[] form = formString.split("=",2); if (form.length==2) { formMap.put(form[0].trim(),form[1].trim()); } }); return formMap; } }
CurlParserUtil { public Map<String, String> getFormBody(String curlLine) { Map<String, String> formMap = new HashMap<>(); String formBodyString = getBodyString(curlLine); String formDataPattern = "([^=&]+=[^&']*)+"; int formDataIndex = 1; List<String> formStringList = RegexUtil.getInstance().getMacthAllResult(formDataPattern, formBodyString, formDataIndex); formStringList.forEach(formString -> { String[] form = formString.split("=",2); if (form.length==2) { formMap.put(form[0].trim(),form[1].trim()); } }); return formMap; } private  CurlParserUtil(); }
CurlParserUtil { public Map<String, String> getFormBody(String curlLine) { Map<String, String> formMap = new HashMap<>(); String formBodyString = getBodyString(curlLine); String formDataPattern = "([^=&]+=[^&']*)+"; int formDataIndex = 1; List<String> formStringList = RegexUtil.getInstance().getMacthAllResult(formDataPattern, formBodyString, formDataIndex); formStringList.forEach(formString -> { String[] form = formString.split("=",2); if (form.length==2) { formMap.put(form[0].trim(),form[1].trim()); } }); return formMap; } 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> getFormBody(String curlLine) { Map<String, String> formMap = new HashMap<>(); String formBodyString = getBodyString(curlLine); String formDataPattern = "([^=&]+=[^&']*)+"; int formDataIndex = 1; List<String> formStringList = RegexUtil.getInstance().getMacthAllResult(formDataPattern, formBodyString, formDataIndex); formStringList.forEach(formString -> { String[] form = formString.split("=",2); if (form.length==2) { formMap.put(form[0].trim(),form[1].trim()); } }); return formMap; } 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);  }