MCPcopy Create free account
hub / github.com/exercism/cli / DumpResponse

Function DumpResponse

debug/debug.go:69–89  ·  view source on GitHub ↗

DumpResponse dumps out the provided http.Response

(res *http.Response)

Source from the content-addressed store, hash-verified

67
68// DumpResponse dumps out the provided http.Response
69func 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 *
92func Redact(token string) string {

Callers 2

DoMethod · 0.92
TestDumpResponseFunction · 0.85

Calls 1

PrintlnFunction · 0.85

Tested by 1

TestDumpResponseFunction · 0.68