mirror of
https://github.com/Xevion/r2park.git
synced 2026-01-31 08:25:22 -06:00
Request/response body debugging for spent buffers
This commit is contained in:
@@ -22,17 +22,20 @@ func DebugRequest(req *http.Request) string {
|
|||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
str += fmt.Sprintf("\n\n {error while reading request body buffer: %s}", err)
|
str += fmt.Sprintf("\n\n {error while reading request body buffer: %s}", err)
|
||||||
|
} else {
|
||||||
|
if len(body) == 0 {
|
||||||
|
str += fmt.Sprintf("\n\n{empty body}")
|
||||||
} else {
|
} else {
|
||||||
str += fmt.Sprintf("\n\n%s", body)
|
str += fmt.Sprintf("\n\n%s", body)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return str
|
return str
|
||||||
}
|
}
|
||||||
|
|
||||||
func DebugResponse(res *http.Response) string {
|
func DebugResponse(res *http.Response) string {
|
||||||
str := fmt.Sprintf("[%s %s]", res.Status, res.Request.URL.String())
|
str := fmt.Sprintf("[%s %s]", res.Status, res.Request.URL.String())
|
||||||
|
|
||||||
// Add all headers
|
// Add all headers
|
||||||
for header_name, header_values := range res.Header {
|
for header_name, header_values := range res.Header {
|
||||||
for _, header_value := range header_values {
|
for _, header_value := range header_values {
|
||||||
@@ -46,10 +49,14 @@ func DebugResponse(res *http.Response) string {
|
|||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
str += fmt.Sprintf("\n\n {error while reading response body buffer: %s}", err)
|
str += fmt.Sprintf("\n\n {error while reading response body buffer: %s}", err)
|
||||||
|
} else {
|
||||||
|
if len(body) == 0 {
|
||||||
|
str += "\n\n{empty body}"
|
||||||
} else {
|
} else {
|
||||||
str += fmt.Sprintf("\n\n%s", body)
|
str += fmt.Sprintf("\n\n%s", body)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return str
|
return str
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user