DumpResponse dumps out the provided http.Response
(res *http.Response)
| 67 | |
| 68 | // DumpResponse dumps out the provided http.Response |
| 69 | func DumpResponse(res *http.Response) { |
| 70 | if !Verbose { |
| 71 | return |
| 72 | } |
| 73 | |
| 74 | var bodyCopy bytes.Buffer |
| 75 | body := io.TeeReader(res.Body, &bodyCopy) |
| 76 | res.Body = io.NopCloser(body) |
| 77 | |
| 78 | dump, err := httputil.DumpResponse(res, res.ContentLength > 0) |
| 79 | if err != nil { |
| 80 | log.Fatal(err) |
| 81 | } |
| 82 | |
| 83 | Println("\n========================= BEGIN DumpResponse =========================") |
| 84 | Println(string(dump)) |
| 85 | Println("========================= END DumpResponse =========================") |
| 86 | Println("") |
| 87 | |
| 88 | res.Body = io.NopCloser(body) |
| 89 | } |
| 90 | |
| 91 | // Redact masks the given token by replacing part of the string with * |
| 92 | func Redact(token string) string { |