From 4059da180bb9d7b0de10c1a041bd0e134f1b6408 Mon Sep 17 00:00:00 2001 From: Kavin <20838718+FireMasterK@users.noreply.github.com> Date: Sun, 3 Jul 2022 02:02:23 +0100 Subject: [PATCH] Allow disabling on the fly webp conversion. --- main.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/main.go b/main.go index 07040de..8c64018 100644 --- a/main.go +++ b/main.go @@ -78,6 +78,7 @@ var path_prefix = "" var manifest_re = regexp.MustCompile(`(?m)URI="([^"]+)"`) var disable_ipv6 = false +var disable_webp = false type requesthandler struct{} @@ -208,7 +209,7 @@ func (*requesthandler) ServeHTTP(w http.ResponseWriter, req *http.Request) { } io.WriteString(w, strings.Join(lines, "\n")) - } else if resp.Header.Get("Content-Type") == "image/jpeg" { + } else if !disable_webp && resp.Header.Get("Content-Type") == "image/jpeg" { img, err := jpeg.Decode(resp.Body) if err != nil { @@ -302,6 +303,7 @@ func main() { path_prefix = os.Getenv("PREFIX_PATH") disable_ipv6 = os.Getenv("DISABLE_IPV6") == "1" + disable_webp = os.Getenv("DISABLE_WEBP") == "1" socket := "socket" + string(os.PathSeparator) + "http-proxy.sock" syscall.Unlink(socket)