mirror of
https://github.com/rclone/rclone.git
synced 2025-12-06 00:03:32 +00:00
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:
@@ -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
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user