diff --git a/src/main/java/utils/HttpClient.java b/src/main/java/utils/HttpClient.java index 390c356..30d3cd9 100644 --- a/src/main/java/utils/HttpClient.java +++ b/src/main/java/utils/HttpClient.java @@ -8,6 +8,8 @@ import burp.IHttpRequestResponse; import burp.IRequestInfo; import entity.HttpService; + +import java.io.BufferedOutputStream; import java.util.HashMap; import java.util.Map; @@ -111,12 +113,11 @@ private void parserRequest(){ continue; } - if (header.indexOf(": ") > 0) { - String key = header.split(": ")[0]; - String value = header.split(": ")[1]; + if (header.indexOf(":") > 0) { + String key = header.substring(0, header.indexOf(":")); + String value = Util.trimStart(header.substring(header.indexOf(":")+1, header.length())); this.headers.put(key, value); } - System.out.println(header); } if (this.method.equals("POST")) { diff --git a/src/main/java/utils/Util.java b/src/main/java/utils/Util.java index ca30b78..55f49c7 100644 --- a/src/main/java/utils/Util.java +++ b/src/main/java/utils/Util.java @@ -303,6 +303,28 @@ public static String matchByRegular(String str,String reg,int n){ return res; } + /** + * 将字符串开头空格去掉 + * @param str + * @return + */ + public static String trimStart(String str) { + if (str == "" || str == null) { + return str; + } - + final char[] value = str.toCharArray(); + int start = 0, last = 0 + str.length() - 1; + int end = last; + while ((start <= end) && (value[start] <= ' ')) { + start++; + } + if (start == 0 && end == last) { + return str; + } + if (start >= end) { + return ""; + } + return str.substring(start, end); + } }