Skip to content

Commit

Permalink
fix: allow 201 for cookies, update header docs (#11472)
Browse files Browse the repository at this point in the history
(cherry picked from commit 5084831)
  • Loading branch information
powersj authored and Sven Rebhan committed Jul 11, 2022
1 parent 595daa8 commit c429d69
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 3 deletions.
3 changes: 2 additions & 1 deletion plugins/common/cookie/cookie.go
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand Down
2 changes: 1 addition & 1 deletion plugins/inputs/http/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
2 changes: 1 addition & 1 deletion plugins/inputs/http/sample.conf
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down

0 comments on commit c429d69

Please sign in to comment.