From d9815da7833fdcc36225d7c726ffa0f55f96cac1 Mon Sep 17 00:00:00 2001 From: Xevion Date: Thu, 28 Dec 2023 14:00:28 -0600 Subject: [PATCH] Use common userAgent const --- helpers.go | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/helpers.go b/helpers.go index 536e2f5..0bfad8d 100644 --- a/helpers.go +++ b/helpers.go @@ -62,10 +62,12 @@ func DoRequest(req *http.Request) (*http.Response, []byte, error) { return resp, body, nil } +const userAgent = "Mozilla/5.0 (X11; Linux x86_64; rv:122.0) Gecko/20100101 Firefox/122.0" + // ApplySclaHeaders applies headers to a request for thescla.org func ApplySclaHeaders(req *http.Request) { req.Header.Set("Origin", "http://www2.thescla.org") - req.Header.Set("User-Agent", "Mozilla/5.0 (X11; Linux x86_64; rv:122.0) Gecko/20100101 Firefox/122.0") + req.Header.Set("User-Agent", userAgent) req.Header.Set("Accept", "application/json, text/javascript, */*; q=0.01") req.Header.Set("Accept-Language", "en-US,en;q=0.5") req.Header.Set("Accept-Encoding", "gzip, deflate") @@ -73,7 +75,7 @@ func ApplySclaHeaders(req *http.Request) { // ApplyUtsaHeaders applies headers to a request for utsa.edu func ApplyUtsaHeaders(req *http.Request) { - req.Header.Set("User-Agent", "Mozilla/5.0 (X11; Linux x86_64; rv:122.0) Gecko/20100101 Firefox/122.0") + req.Header.Set("User-Agent", userAgent) req.Header.Set("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,*/*;q=0.8") req.Header.Set("Accept-Language", "en-US,en;q=0.5") req.Header.Set("Accept-Encoding", "gzip, deflate")