From a05c4d597eab79f9ee3fd2e113d9dd8dffbd55db Mon Sep 17 00:00:00 2001 From: yinheli Date: Thu, 5 Jan 2023 18:23:47 +0800 Subject: [PATCH] fix: requests dump panic --- pkg/requests/requests.go | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/pkg/requests/requests.go b/pkg/requests/requests.go index 08517f5..5e4e035 100644 --- a/pkg/requests/requests.go +++ b/pkg/requests/requests.go @@ -114,6 +114,7 @@ type requests struct { // Response hold response context & data with debug information type Response struct { + request *http.Request err error escape time.Duration response *http.Response @@ -297,6 +298,7 @@ func (t *requests) Do() *Response { return r } r.cnt += 1 + r.request = req rsp, err := t.client.Do(req) if err != nil { if t.retry != nil { @@ -341,8 +343,8 @@ func (t *Response) Dump(body bool) map[string]interface{} { dump["error"] = t.err } - if t.response != nil && t.response.Request != nil { - if b, err := httputil.DumpRequest(t.response.Request, body); err == nil { + if t.response != nil && t.request != nil { + if b, err := httputil.DumpRequestOut(t.request, body); err == nil { dump["request"] = string(b) } }