diff --git a/plugins/inputs/influxdb_listener/http_listener.go b/plugins/inputs/influxdb_listener/http_listener.go index b8abeecd7..29f055b53 100644 --- a/plugins/inputs/influxdb_listener/http_listener.go +++ b/plugins/inputs/influxdb_listener/http_listener.go @@ -254,12 +254,12 @@ func (h *HTTPListener) serveWrite(res http.ResponseWriter, req *http.Request) { if req.Header.Get("Content-Encoding") == "gzip" { var err error body, err = gzip.NewReader(req.Body) - defer body.Close() if err != nil { log.Println("D! " + err.Error()) badRequest(res, err.Error()) return } + defer body.Close() } body = http.MaxBytesReader(res, body, h.MaxBodySize.Size)