aboutsummaryrefslogtreecommitdiff
path: root/http.go
diff options
context:
space:
mode:
authorMitchell Riedstra <mitch@riedstra.dev>2021-07-26 16:58:25 -0400
committerMitchell Riedstra <mitch@riedstra.dev>2021-07-26 16:58:25 -0400
commit1cebf3b440a35d532b51a13f4b3dd1a90e8cdab2 (patch)
treefde1b24a768c5d454ddbf544d3d6a32009689ed0 /http.go
parent4a4c36edde5ff9580b3ef5342d67b0117d555b61 (diff)
downloadcheckup-1cebf3b440a35d532b51a13f4b3dd1a90e8cdab2.tar.gz
checkup-1cebf3b440a35d532b51a13f4b3dd1a90e8cdab2.tar.xz
hack at it a bit to support checking for things that should not redirectHEADmaster
Diffstat (limited to 'http.go')
-rw-r--r--http.go22
1 files changed, 19 insertions, 3 deletions
diff --git a/http.go b/http.go
index daf8945..75f657b 100644
--- a/http.go
+++ b/http.go
@@ -1,14 +1,13 @@
package checkup
import (
+ "errors"
"fmt"
"net/http"
"time"
)
-func HttpStatusOK(url string, timeout, status int) error {
- client := &http.Client{Timeout: time.Duration(timeout) * time.Second}
-
+func httpReq(client *http.Client, url string, timeout, status int) error {
resp, err := client.Get(url)
if err != nil {
@@ -24,3 +23,20 @@ func HttpStatusOK(url string, timeout, status int) error {
return nil
}
+
+func HttpStatusOK(url string, timeout, status int) error {
+ client := &http.Client{Timeout: time.Duration(timeout) * time.Second}
+ return httpReq(client, url, timeout, status)
+}
+
+func HttpNoRedirectStatusOK(url string, timeout, status int) error {
+ client := &http.Client{
+ Timeout: time.Duration(timeout) * time.Second,
+ CheckRedirect: httpNoRedirectfunc,
+ }
+ return httpReq(client, url, timeout, status)
+}
+
+func httpNoRedirectfunc(req *http.Request, via []*http.Request) error {
+ return errors.New("Redirected")
+}