]> Sergey Matveev's repositories - tofuproxy.git/blobdiff - trip.go
Fix various lint warnings and suggestions
[tofuproxy.git] / trip.go
diff --git a/trip.go b/trip.go
index 1b9a84538cc89de6dc143d49d5fecaf936451dac..0e179a5b00aabdfd70b97d8d956f6ffbfd41a5c4 100644 (file)
--- a/trip.go
+++ b/trip.go
@@ -1,20 +1,18 @@
-/*
-tofuproxy -- flexible HTTP/HTTPS proxy, TLS terminator, X.509 TOFU
-             manager, WARC/geminispace browser
-Copyright (C) 2021-2022 Sergey Matveev <stargrave@stargrave.org>
-
-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
-the Free Software Foundation, version 3 of the License.
-
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with this program.  If not, see <http://www.gnu.org/licenses/>.
-*/
+// tofuproxy -- flexible HTTP/HTTPS proxy, TLS terminator, X.509 TOFU
+//              manager, WARC/geminispace browser
+// Copyright (C) 2021-2024 Sergey Matveev <stargrave@stargrave.org>
+//
+// 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
+// the Free Software Foundation, version 3 of the License.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
 package tofuproxy
 
@@ -65,7 +63,6 @@ func roundTrip(w http.ResponseWriter, req *http.Request) {
        fifos.LogReq <- fmt.Sprintf("%s %s", req.Method, req.URL)
        host := strings.TrimSuffix(req.URL.Host, ":443")
        for _, round := range []Round{
-               rounds.RoundNoHead,
                rounds.RoundGemini,
                rounds.RoundWARC,
                rounds.RoundDenySpy,
@@ -106,7 +103,8 @@ Retry:
                fifos.LogVarious <- fmt.Sprintf(
                        "%s %s\tHTTP authorization required", req.Method, req.URL.Host,
                )
-               user, pass, err := authDialog(host, resp.Header.Get("WWW-Authenticate"))
+               var user, pass string
+               user, pass, err = authDialog(host, resp.Header.Get("WWW-Authenticate"))
                if err != nil {
                        caches.HTTPAuthCacheM.Unlock()
                        fifos.LogErr <- fmt.Sprintf("%s\t%s", req.URL.Host, err.Error())
@@ -135,20 +133,23 @@ Retry:
                }
        }
 
-       for _, round := range []Round{
-               rounds.RoundDenyFonts,
-               rounds.RoundTranscodeWebP,
-               rounds.RoundTranscodeJXL,
-               rounds.RoundTranscodeAVIF,
-               rounds.RoundRedirectHTML,
-       } {
-               cont, err := round(host, resp, w, req)
-               if err != nil {
-                       http.Error(w, err.Error(), http.StatusBadGateway)
-                       return
-               }
-               if !cont {
-                       return
+       {
+               var cont bool
+               for _, round := range []Round{
+                       rounds.RoundDenyFonts,
+                       rounds.RoundTranscodeWebP,
+                       rounds.RoundTranscodeJXL,
+                       rounds.RoundTranscodeAVIF,
+                       rounds.RoundRedirectHTML,
+               } {
+                       cont, err = round(host, resp, w, req)
+                       if err != nil {
+                               http.Error(w, err.Error(), http.StatusBadGateway)
+                               return
+                       }
+                       if !cont {
+                               return
+                       }
                }
        }