We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
Hi,
I am kindly asking you to change the watchdog-tomcat.go code, so that it also accepts http status code 3xx instead of 200 only.
watchdog-tomcat.go
My change is as diff is:
diff --git a/watchdog-tomcat.go b/watchdog-tomcat.go index d1b8612..cf792d3 100644 --- a/watchdog-tomcat.go +++ b/watchdog-tomcat.go @@ -72,13 +72,20 @@ func runWatchedApp(application string) (pid int, err error) { func healthCheck(check_url string, timeout time.Duration) (bool, error) { var netClient = &http.Client{ Timeout: time.Second * timeout, + CheckRedirect: func(req *http.Request, via []*http.Request) error { + return http.ErrUseLastResponse + }, } resp, err := netClient.Get(check_url) if err != nil { return false, err } - if resp.StatusCode != 200 { - return false, errors.New("health check status is not 200") + if resp.StatusCode == 200 { + return true, nil + } else if resp.StatusCode >= 300 && resp.StatusCode < 400 { + return true, nil + } else { + return false, errors.New("health check status is not 200 or 3xx") } defer resp.Body.Close() return true, nil @@ -186,4 +193,4 @@ func main() { } }(check_url) wg.Wait() }
I followed this post for making the change. https://stackoverflow.com/questions/23297520/how-can-i-make-the-go-http-client-not-follow-redirects-automatically
It would be nice, if you can put my change to branch master.
Thx.
The text was updated successfully, but these errors were encountered:
Cover issues #1, xiaotuanyu120#2 and fix wrong defer
d32fbb2
No branches or pull requests
Hi,
I am kindly asking you to change the
watchdog-tomcat.go
code, so that it also accepts http status code 3xx instead of 200 only.My change is as diff is:
I followed this post for making the change.
https://stackoverflow.com/questions/23297520/how-can-i-make-the-go-http-client-not-follow-redirects-automatically
It would be nice, if you can put my change to branch master.
Thx.
The text was updated successfully, but these errors were encountered: