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