Skip to content

Commit

Permalink
fix: requests dump panic
Browse files Browse the repository at this point in the history
  • Loading branch information
yinheli committed Jan 5, 2023
1 parent 488195b commit a05c4d5
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions pkg/requests/requests.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -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)
}
}
Expand Down

0 comments on commit a05c4d5

Please sign in to comment.