Skip to content
This repository has been archived by the owner on Jul 25, 2024. It is now read-only.

Commit

Permalink
Allow disabling on the fly webp conversion.
Browse files Browse the repository at this point in the history
  • Loading branch information
FireMasterK committed Jul 3, 2022
1 parent 0816001 commit 4059da1
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion main.go
Original file line number Diff line number Diff line change
Expand Up @@ -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{}

Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit 4059da1

Please sign in to comment.