X-Git-Url: http://www.git.stargrave.org/?a=blobdiff_plain;f=rounds%2FredirectHTML.go;h=abc657e6546a8926d249f5eb0c418c50d32a7698;hb=29146b48a23355805345a7b7a656809cf624bb85;hp=2bf4ce2b25b7d2dca6ecc1409c557fd3756d5ac1;hpb=1b3ef99af2896156902264aaccced15426874484;p=tofuproxy.git diff --git a/rounds/redirectHTML.go b/rounds/redirectHTML.go index 2bf4ce2..abc657e 100644 --- a/rounds/redirectHTML.go +++ b/rounds/redirectHTML.go @@ -1,6 +1,7 @@ /* -tofuproxy -- HTTP proxy with TLS certificates management -Copyright (C) 2021 Sergey Matveev +tofuproxy -- flexible HTTP/HTTPS proxy, TLS terminator, X.509 TOFU + manager, WARC/geminispace browser +Copyright (C) 2021-2023 Sergey Matveev This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -43,8 +44,14 @@ var imageExts = map[string]struct{}{ ".webp": {}, } -func isNewsboat(req *http.Request) bool { - return strings.Contains(req.Header.Get("User-Agent"), "newsboat/") +func isFeeder(req *http.Request) bool { + if strings.Contains(req.Header.Get("User-Agent"), "newsboat/") { + return true + } + if strings.Contains(req.Header.Get("User-Agent"), "stargrave.org-feeder/") { + return true + } + return false } func RoundRedirectHTML( @@ -61,7 +68,7 @@ func RoundRedirectHTML( case http.StatusMovedPermanently, http.StatusPermanentRedirect: redirType = "permanent" case http.StatusFound, http.StatusSeeOther, http.StatusTemporaryRedirect: - if isNewsboat(req) { + if isFeeder(req) { return true, nil } if _, ok := imageExts[filepath.Ext(req.URL.Path)]; ok { @@ -77,8 +84,9 @@ func RoundRedirectHTML( location := resp.Header.Get("Location") w.Write([]byte( fmt.Sprintf( - `%d %s: %s redirection -Redirection to %s`, + ` +%d %s: %s redirection +%s`, resp.StatusCode, http.StatusText(resp.StatusCode), redirType, location, location, )))