From 381a6573b5fda9f83d17278565c78fad440f9ee7 Mon Sep 17 00:00:00 2001 From: Filippo Valsorda Date: Thu, 31 Jul 2025 15:12:21 +0200 Subject: [PATCH 1/2] Add User-Agent header --- main.go | 1 + 1 file changed, 1 insertion(+) diff --git a/main.go b/main.go index 1dc0962..2d13397 100644 --- a/main.go +++ b/main.go @@ -124,6 +124,7 @@ func downloadJSON(url string) ([]byte, *http.Response, error) { return []byte{}, nil, err } + req.Header.Set("User-Agent", "ctail (+https://github.com/hdm/ctail)") req.Header.Set("Accept", "application/json") tr := &http.Transport{ From 4d564b46a5c113cca266bdd0d44bbc64f7c283da Mon Sep 17 00:00:00 2001 From: Filippo Valsorda Date: Thu, 31 Jul 2025 15:15:27 +0200 Subject: [PATCH 2/2] Reuse http.Client --- main.go | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/main.go b/main.go index 2d13397..ee98f2f 100644 --- a/main.go +++ b/main.go @@ -118,6 +118,10 @@ func scrubX509Value(s string) string { return strings.ReplaceAll(s, "\x00", "") } +var client = &http.Client{Transport: &http.Transport{ + TLSClientConfig: &tls.Config{InsecureSkipVerify: true}, +}} + func downloadJSON(url string) ([]byte, *http.Response, error) { req, err := http.NewRequest("GET", url, nil) if err != nil { @@ -127,12 +131,6 @@ func downloadJSON(url string) ([]byte, *http.Response, error) { req.Header.Set("User-Agent", "ctail (+https://github.com/hdm/ctail)") req.Header.Set("Accept", "application/json") - tr := &http.Transport{ - TLSClientConfig: &tls.Config{InsecureSkipVerify: true}, - } - - client := &http.Client{Transport: tr} - resp, err := client.Do(req) if err != nil { return []byte{}, resp, err