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

[check-http] Add --max-redirects option #249

Merged
merged 2 commits into from
Sep 7, 2018
Merged

[check-http] Add --max-redirects option #249

merged 2 commits into from
Sep 7, 2018

Conversation

nonylene
Copy link
Contributor

@nonylene nonylene commented Sep 6, 2018

check-http cannot check redirects currently since http.Client follow redirects by default.

In this PR, I added --max-redirects option (like --max-redirs in curl or --max-redirect in wget) by setting client.checkRedirect.

Example

$ ./mackerel-check http --help
Usage:
 mackerel-check [OPTIONS]

Application Options:
 -u, --url=                  A URL to connect to
 -s, --status=               mapping of HTTP status
     --no-check-certificate  Do not check certificate
 -i, --source-ip=            source IP address
 -H=                         HTTP request headers
 -p, --pattern=              Expected pattern in the content
     --max-redirects=        Maximum number of redirects followed (default: 10)

Help Options:
 -h, --help                  Show this help message

$ ./mackerel-check http --max-redirects=1 -u http://mackerel.io/
HTTP OK: HTTP/1.1 200 OK - 35343 bytes in 5.142627 second response time

$ ./mackerel-check http --max-redirects=0 -u http://mackerel.io/
HTTP OK: HTTP/1.1 301 Moved Permanently - 178 bytes in 0.008557 second response time

@susisu
Copy link
Contributor

susisu commented Sep 7, 2018

LGTM! Thank you.

@susisu susisu merged commit ac5388f into mackerelio:master Sep 7, 2018
@nonylene nonylene deleted the check-http-max-redirects branch September 7, 2018 05:53
@yuuki yuuki mentioned this pull request Sep 13, 2018
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 this pull request may close these issues.

2 participants