|
|
@ -12,7 +12,7 @@ import ( |
|
|
|
"strconv" |
|
|
|
"strconv" |
|
|
|
) |
|
|
|
) |
|
|
|
|
|
|
|
|
|
|
|
func httpDump(req *http.Request, resp *http.Response) { |
|
|
|
func httpDump(reqDump []byte, resp *http.Response) { |
|
|
|
defer resp.Body.Close() |
|
|
|
defer resp.Body.Close() |
|
|
|
var respStatusStr string |
|
|
|
var respStatusStr string |
|
|
|
respStatus := resp.StatusCode |
|
|
|
respStatus := resp.StatusCode |
|
|
@ -27,19 +27,33 @@ func httpDump(req *http.Request, resp *http.Response) { |
|
|
|
case 5: |
|
|
|
case 5: |
|
|
|
respStatusStr = Red("<--" + strconv.Itoa(respStatus)) |
|
|
|
respStatusStr = Red("<--" + strconv.Itoa(respStatus)) |
|
|
|
} |
|
|
|
} |
|
|
|
fmt.Println(Green("Request:")) |
|
|
|
fmt.Println(Green("Request:"), respStatusStr) |
|
|
|
fmt.Printf("%s %s %s\n", Blue(req.Method), req.RequestURI, respStatusStr) |
|
|
|
ParseReq(reqDump) |
|
|
|
|
|
|
|
/*req, _ := ParseReq(reqDump) |
|
|
|
|
|
|
|
for k, v := range req { |
|
|
|
|
|
|
|
fmt.Println(k, ":::::", v) |
|
|
|
|
|
|
|
}*/ |
|
|
|
|
|
|
|
/*fmt.Printf("%s %s %s\n", Blue(req.Method), req.RequestURI, respStatusStr) |
|
|
|
for headerName, headerContext := range req.Header { |
|
|
|
for headerName, headerContext := range req.Header { |
|
|
|
fmt.Printf("%s: %s\n", Blue(headerName), headerContext) |
|
|
|
fmt.Printf("%s: %s\n", Blue(headerName), headerContext) |
|
|
|
} |
|
|
|
}*/ |
|
|
|
if req.Method == "POST" { |
|
|
|
/*if req.Method == "POST" { |
|
|
|
fmt.Println(Green("URLEncoded form")) |
|
|
|
fmt.Println(Green("URLEncoded form")) |
|
|
|
|
|
|
|
|
|
|
|
for k, v := range req.Form { |
|
|
|
err := req.ParseForm() |
|
|
|
|
|
|
|
if err != nil { |
|
|
|
|
|
|
|
logger.Println("parseForm error:", err) |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
for k, v := range req.Form { |
|
|
|
|
|
|
|
fmt.Printf("%s: %s\n", Blue(k), v) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
values, _ := ParsePostValues(reqDump) |
|
|
|
|
|
|
|
for k, v := range values { |
|
|
|
fmt.Printf("%s: %s\n", Blue(k), v) |
|
|
|
fmt.Printf("%s: %s\n", Blue(k), v) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
}*/ |
|
|
|
fmt.Println(Green("Response:")) |
|
|
|
fmt.Println(Green("Response:")) |
|
|
|
for headerName, headerContext := range resp.Header { |
|
|
|
for headerName, headerContext := range resp.Header { |
|
|
|
fmt.Printf("%s: %s\n", Blue(headerName), headerContext) |
|
|
|
fmt.Printf("%s: %s\n", Blue(headerName), headerContext) |
|
|
@ -77,3 +91,8 @@ func httpDump(req *http.Request, resp *http.Response) { |
|
|
|
|
|
|
|
|
|
|
|
fmt.Printf("%s%s%s\n", Black("####################"), Cyan("END"), Black("####################")) |
|
|
|
fmt.Printf("%s%s%s\n", Black("####################"), Cyan("END"), Black("####################")) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
func ParseReq(b []byte) error { |
|
|
|
|
|
|
|
str := string(b) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|