Browse Source

Merge branch '_log_leftover_url' into _product

pull/5936/head
changlin.shi 2 years ago
parent
commit
834f4cc7ee
  1. 9
      weed/util/http_util.go

9
weed/util/http_util.go

@ -415,17 +415,26 @@ func CloseResponse(resp *http.Response) {
io.Copy(io.Discard, reader) io.Copy(io.Discard, reader)
resp.Body.Close() resp.Body.Close()
if reader.BytesRead > 0 { if reader.BytesRead > 0 {
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) glog.V(1).Infof("response leftover %d bytes", reader.BytesRead)
} }
} }
}
func CloseRequest(req *http.Request) { func CloseRequest(req *http.Request) {
reader := &CountingReader{reader: req.Body} reader := &CountingReader{reader: req.Body}
io.Copy(io.Discard, reader) io.Copy(io.Discard, reader)
req.Body.Close() req.Body.Close()
if reader.BytesRead > 0 { if reader.BytesRead > 0 {
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) glog.V(1).Infof("request leftover %d bytes", reader.BytesRead)
} }
}
} }
type CountingReader struct { type CountingReader struct {

Loading…
Cancel
Save