From 50b06cfceceab7c98df612c06fa48ac0c7afc3ef Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?M=2E=20=C3=81ngel?= Date: Sat, 10 Jun 2017 16:03:19 +0200 Subject: [PATCH] Beeping now doesn't follow redirects --- beeping.go | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/beeping.go b/beeping.go index c0cd9f9..86986ec 100644 --- a/beeping.go +++ b/beeping.go @@ -230,18 +230,24 @@ func CheckHTTP(check *Check) (*Response, error) { timeout := time.Duration(check.Timeout * time.Second) - client := &http.Client{Transport: tr, Timeout: timeout} + client := &http.Client{ + Transport: tr, + Timeout: timeout, + CheckRedirect: func(req *http.Request, via []*http.Request) error { + return http.ErrUseLastResponse + }, + } res, err := client.Do(req) if err != nil { return nil, err } + defer res.Body.Close() body, err := ioutil.ReadAll(res.Body) if err != nil { return nil, err } - res.Body.Close() timeEndBody := time.Now() result.End(timeEndBody) var total = result.Total(timeEndBody)