Return error if NewRequest fails in http output (#4429)

This commit is contained in:
Greg 2018-07-17 15:54:10 -06:00 committed by GitHub
parent 3218ed7e0d
commit b75d66ff41
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 3 additions and 0 deletions

View File

@ -127,6 +127,9 @@ func (h *HTTP) Write(metrics []telegraf.Metric) error {
func (h *HTTP) write(reqBody []byte) error {
req, err := http.NewRequest(h.Method, h.URL, bytes.NewBuffer(reqBody))
if err != nil {
return err
}
req.Header.Set("Content-Type", defaultContentType)
for k, v := range h.Headers {