Browse Source

log leftover with url if present

Signed-off-by: changlin.shi <changlin.shi@ly.com>
pull/5936/head
changlin.shi 2 years ago
parent
commit
930fa47699
  1. 13
      weed/util/http_util.go

13
weed/util/http_util.go

@ -415,7 +415,11 @@ func CloseResponse(resp *http.Response) {
io.Copy(io.Discard, reader)
resp.Body.Close()
if reader.BytesRead > 0 {
glog.V(1).Infof("response leftover %d bytes", reader.BytesRead)
if resp.Request != nil && resp.Request.URL != nil {
glog.V(1).Infof("response leftover %d bytes, url: %s", resp.Request.URL.RequestURI())
} else {
glog.V(1).Infof("response leftover %d bytes", reader.BytesRead)
}
}
}
@ -424,7 +428,12 @@ func CloseRequest(req *http.Request) {
io.Copy(io.Discard, reader)
req.Body.Close()
if reader.BytesRead > 0 {
glog.V(1).Infof("request leftover %d bytes", reader.BytesRead)
if req.URL != nil {
glog.V(1).Infof("request leftover %d bytes, url: %s", reader.BytesRead, req.URL.RequestURI())
} else {
glog.V(1).Infof("request leftover %d bytes", reader.BytesRead)
}
}
}

Loading…
Cancel
Save