Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

implement --response-code functionality #16

Open
agoddard opened this issue Mar 28, 2022 · 9 comments
Open

implement --response-code functionality #16

agoddard opened this issue Mar 28, 2022 · 9 comments
Assignees
Milestone

Comments

@agoddard
Copy link

Allow checking for an expected http status code, exiting 0 if the expected code matches the returned code. This is to implement checks to ensure that a site responds with a particular status code, such as a 403, or a 301. For reference, in the legacy ruby version of this plugin, this functionality was implemented as --response code <code> https://github.com/sensu-plugins/sensu-plugins-http/blob/master/bin/check-http.rb#L30-L31

@calebhailey
Copy link

calebhailey commented Mar 28, 2022

@jspaleta I wonder if we could implement this one as a metric tag + metric threshold check?

@nixwiz
Copy link
Contributor

nixwiz commented Mar 29, 2022

@agoddard something to consider in implementing this would be its behavior with respect to the --redirect-ok flag. May require additional documentation (e.g. you cannot use --redirect-ok when doing --response-code 301) and the already noted caveats for --redirect-ok.

@c-kruse c-kruse self-assigned this Apr 5, 2022
@asachs01
Copy link

@agoddard is there an internal ref for this one?

@calebhailey
Copy link

I'm wondering if --redirect-ok and the proposed --reponse-code implementation are necessarily mutually exclusive? What if I want to configure a check to expect a response-code from it's final destination, even if that's after following a redirect?

@calebhailey
Copy link

Should --response-code be --response-codes (plural)? Then perhaps you could pair --redirect-ok with --response-codes 301,202, meaning any number of 301 redirects and a 202 response code are acceptable result for the check?

@agoddard
Copy link
Author

Maybe it can be a single code or an array, and when it is an array the order matters, so then you can say "when I hit this redirecting URL with redirect-ok, I want to know that the place I end up gives me a 200" and then of providing an Array, then "when I hit this redirecting URL, I should get a 302 on the way to the 200" [302,200]

@calebhailey calebhailey added this to the 6.8.0 milestone Jun 9, 2022
@calebhailey calebhailey self-assigned this Aug 9, 2022
@fguimond
Copy link

fguimond commented Feb 6, 2024

Let’s implement the suggested changes allowing the concurrent usage of --redirect-ok and --response-code, by applying the response code validation against the final redirect destination. --response-code should allow for a coma-separated list of valid response codes. As an example --response-code '200,201' would allow the final response code to be either 200 or 201.

@chavakula
Copy link
Contributor

@fguimond , pull request has been raised for the same : #28

@fguimond
Copy link

@fguimond to release the next version of the plugin.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

7 participants