From 21079b04f6c573324ea1b854255e73d6f6188979 Mon Sep 17 00:00:00 2001 From: delthas Date: Thu, 19 Mar 2026 17:12:57 +0100 Subject: [PATCH 51/54] Set User-Agent header in fetchImage HTTP requests Image fetching timed out on some hosts (e.g. catbox.moe) because Go's default HTTP client sends "Go-http-client/2.0" as the User-Agent when HTTP/2 is negotiated, which certain servers silently block by never sending response headers. Set a "senpai/" (or "senpai") User-Agent on all HTTP requests in fetchImage (HEAD, HTML GET, and image GET). Also close the HEAD response body and fix minor whitespace. Fixes: https://todo.sr.ht/~delthas/senpai/230 --- app.go | 25 +++++++++++++++++++++---- 1 file changed, 21 insertions(+), 4 deletions(-) diff --git a/app.go b/app.go index 697ffbd..e781c0f 100644 --- a/app.go +++ b/app.go @@ -243,7 +243,7 @@ func NewApp(cfg Config) (app *App, err error) { } func (app *App) Close() { - app.win.Exit() // tell all instances of app.ircLoop to stop when possible + app.win.Exit() // tell all instances of app.ircLoop to stop when possible app.postEvent(event{ // tell app.eventLoop to stop src: "*", content: nil, @@ -1204,6 +1204,11 @@ var patternOpenGraphImage = regexp.MustCompile(`