From 508483157d104449a4976129f04e822761eeb97a Mon Sep 17 00:00:00 2001 From: Joshua Powers Date: Fri, 8 Jul 2022 15:10:46 -0600 Subject: [PATCH] fix: allow 201 for cookies, update header docs (#11472) --- plugins/common/cookie/cookie.go | 3 ++- plugins/inputs/http/README.md | 2 +- plugins/inputs/http/sample.conf | 2 +- 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/plugins/common/cookie/cookie.go b/plugins/common/cookie/cookie.go index 63dee4858..e2e431aae 100644 --- a/plugins/common/cookie/cookie.go +++ b/plugins/common/cookie/cookie.go @@ -110,7 +110,8 @@ func (c *CookieAuthConfig) auth() error { return err } - if resp.StatusCode != http.StatusOK { + // check either 200 or 201 as some devices may return either + if resp.StatusCode != http.StatusOK && resp.StatusCode != http.StatusCreated { return fmt.Errorf("cookie auth renewal received status code: %v (%v)", resp.StatusCode, http.StatusText(resp.StatusCode), diff --git a/plugins/inputs/http/README.md b/plugins/inputs/http/README.md index f94917a7b..c96d56bcf 100644 --- a/plugins/inputs/http/README.md +++ b/plugins/inputs/http/README.md @@ -58,7 +58,7 @@ configuration. # cookie_auth_method = "POST" # cookie_auth_username = "username" # cookie_auth_password = "pa$$word" - # cookie_auth_headers = '{"Content-Type": "application/json", "X-MY-HEADER":"hello"}' + # cookie_auth_headers = { Content-Type = "application/json", X-MY-HEADER = "hello" } # cookie_auth_body = '{"username": "user", "password": "pa$$word", "authenticate": "me"}' ## cookie_auth_renewal not set or set to "0" will auth once and never renew the cookie # cookie_auth_renewal = "5m" diff --git a/plugins/inputs/http/sample.conf b/plugins/inputs/http/sample.conf index 2d8b6116e..9c38fb9b0 100644 --- a/plugins/inputs/http/sample.conf +++ b/plugins/inputs/http/sample.conf @@ -47,7 +47,7 @@ # cookie_auth_method = "POST" # cookie_auth_username = "username" # cookie_auth_password = "pa$$word" - # cookie_auth_headers = '{"Content-Type": "application/json", "X-MY-HEADER":"hello"}' + # cookie_auth_headers = { Content-Type = "application/json", X-MY-HEADER = "hello" } # cookie_auth_body = '{"username": "user", "password": "pa$$word", "authenticate": "me"}' ## cookie_auth_renewal not set or set to "0" will auth once and never renew the cookie # cookie_auth_renewal = "5m"