MCPcopy Create free account
hub / github.com/c0ny1/captcha-killer / processLine

Method processLine

src/main/java/utils/HttpClient.java:47–82  ·  view source on GitHub ↗

将请求包头中\n替换为\r\n,因为\n可能会导致某些服务器报错,无法正确识别请求包。 @param reqraw @return

(String reqraw)

Source from the content-addressed store, hash-verified

45 * @return
46 */
47 public String processLine(String reqraw){
48 String method = null;
49 String header = null;
50 String body = null;
51 String request = null;
52
53 if(reqraw.startsWith("GET")){
54 method = "GET";
55 }else if(reqraw.startsWith("POST")){
56 method = "POST";
57 }else{
58 method = "unkown";
59 return reqraw;
60 }
61
62 if(method.equals("GET")) {
63 header = reqraw;
64
65 //将所有\n替换为\r\n,注意\r\n和\n混合情况下的替换。
66 header.replace("\r\n","\n");
67 header.replace("\n","\r\n");
68
69 request = header;
70 }
71
72 if(method.equals("POST")){
73 int n = reqraw.indexOf("\n\n") != -1 ? reqraw.indexOf("\n\n") : reqraw.indexOf("\r\n\r\n");
74 header = reqraw.substring(0, n).trim();
75 body = reqraw.substring(n + 1, reqraw.length()).trim();
76 if(header.indexOf("\n")>=0 && header.indexOf("\r\n") <0){
77 header = header.replace("\n","\r\n");
78 }
79 request = header + "\r\n\r\n" + body;
80 }
81 return request;
82 }
83
84
85 public String getHttpService(){

Callers 1

HttpClientMethod · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected