From 5b9fc934e7ef371ae64a3fc654da1fbc5c2689b6 Mon Sep 17 00:00:00 2001 From: Daniel Rocha Date: Wed, 17 Jun 2020 20:14:26 +0200 Subject: [PATCH] Code clean-up --- htp.go | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/htp.go b/htp.go index b5792a0..b1e4855 100644 --- a/htp.go +++ b/htp.go @@ -30,15 +30,16 @@ func main() { } logger := log.New(os.Stderr, "", 0) - client := http.DefaultClient - client.CheckRedirect = noRedirect + client := &http.Client{} client.Timeout = 10 * time.Second + client.CheckRedirect = func(req *http.Request, via []*http.Request) error { + return http.ErrUseLastResponse + } req, err := http.NewRequest("HEAD", opts.host, nil) if err != nil { logger.Fatal("Invalid HTTP request: ", err) } - req.Header.Add("Cache-Control", "no-cache") var ( t0, t1 int64 @@ -144,7 +145,3 @@ func mod(x, m int64) int64 { } return m + y } - -func noRedirect(req *http.Request, via []*http.Request) error { - return http.ErrUseLastResponse -}