forked from TrueCloudLab/rclone
Fix crash in http logging - fixes #223
A nil-pointer exception was caused if the http transaction ever resulted in a go error while using `--dump-bodies`. Now don't ignore the error and log it instead of the http body.
This commit is contained in:
parent
36f1bc4a8a
commit
8057d668bb
1 changed files with 6 additions and 2 deletions
|
@ -48,10 +48,14 @@ func (t *LoggedTransport) RoundTrip(req *http.Request) (resp *http.Response, err
|
|||
log.Println(string(buf))
|
||||
log.Println(separatorReq)
|
||||
resp, err = t.wrapped.RoundTrip(req)
|
||||
buf, _ = httputil.DumpResponse(resp, t.logBody)
|
||||
log.Println(separatorResp)
|
||||
log.Println("HTTP RESPONSE")
|
||||
log.Println(string(buf))
|
||||
if err != nil {
|
||||
log.Printf("Error: %v\n", err)
|
||||
} else {
|
||||
buf, _ = httputil.DumpResponse(resp, t.logBody)
|
||||
log.Println(string(buf))
|
||||
}
|
||||
log.Println(separatorResp)
|
||||
return resp, err
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue