Fix influxdb output serialization on connection closed (#6621)

This commit is contained in:
陈方舟
2019-11-14 04:56:01 +08:00
committed by Daniel Nelson
parent 9a2b3bc917
commit fa2f0fff4e
8 changed files with 132 additions and 37 deletions

View File

@@ -153,6 +153,7 @@ func (h *HTTP) gatherURL(
if err != nil {
return err
}
defer body.Close()
request, err := http.NewRequest(h.Method, url, body)
if err != nil {
@@ -216,16 +217,16 @@ func (h *HTTP) gatherURL(
return nil
}
func makeRequestBodyReader(contentEncoding, body string) (io.Reader, error) {
var err error
func makeRequestBodyReader(contentEncoding, body string) (io.ReadCloser, error) {
var reader io.Reader = strings.NewReader(body)
if contentEncoding == "gzip" {
reader, err = internal.CompressWithGzip(reader)
rc, err := internal.CompressWithGzip(reader)
if err != nil {
return nil, err
}
return rc, nil
}
return reader, nil
return ioutil.NopCloser(reader), nil
}
func init() {