fuzzyworld

quantum-inspiration / commit

add user agent

5de7703cc9d1d642bbec7c5fba48649f5ef6e0be · Pavel Safronov · 2025-08-31 11:06:27 -0700 · parents 62dbc0bcd382

add user agent
this is related to: https://phabricator.wikimedia.org/T400119
 http-cache.go | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)

diff --git a/http-cache.go b/http-cache.go
index ccac112..d46ad84 100644
--- a/http-cache.go
+++ b/http-cache.go
@@ -51,7 +51,15 @@ func getCachedUrlFunc(
 		}
 		return bytes, nil
 	} else {
-		resp, err := http.Get(url)
+		client := http.Client{}
+
+		req, err := http.NewRequest("GET", url, nil)
+		if err != nil {
+			return nil, err
+		}
+		req.Header.Set("User-Agent", "QuantumInspirationBot/1.0 (https://pavelsafronov.gitlab.io/quantum-inspiration/)")
+
+		resp, err := client.Do(req)
 		if err != nil {
 			return nil, err
 		}