Currently the request body is closed even, when the logger is not defined:
|
defer func() { |
|
if request.Body != nil { |
|
request.Body.Close() |
|
} |
|
}() |
It should be closed only when the logger is defined, e.g.:
defer func() {
if rt.Logger != nil && request.Body != nil {
request.Body.Close()
}
}()
AFAIK it is not a big deal, because in most cases original RoundTrip closes the request body, but I think there could rare cases with bad connection, when this is not happened and this can lead to a memory leak.
@jtopjian objections, anything to add?