]> Sergey Matveev's repositories - tofuproxy.git/commitdiff
Xombrero does not send User-Agent with HEAD
authorSergey Matveev <stargrave@stargrave.org>
Tue, 7 Sep 2021 21:51:02 +0000 (00:51 +0300)
committerSergey Matveev <stargrave@stargrave.org>
Tue, 7 Sep 2021 21:51:02 +0000 (00:51 +0300)
doc/index.texi
rounds/05noHead.go
rounds/40transcodeWebP.go

index 0d27a68707f7792bed0724ec1e5168d36107b72c..7759710db9072ac1680b4537399fd194ebbac836 100644 (file)
@@ -61,7 +61,8 @@ creating some kind of complex configuration framework.
 @item TLS connection between client and @command{tofuproxy} has the
     proper hostname set in ephemeral on-the-fly generated certificate.
 
-@item @code{HEAD} method for Xombrero is forbidden, as it loves it too much.
+@item @code{HEAD} method is forbidden, as Xombrero loves it too much and
+    it does not send User-Agent to differentiate it from others.
 
 @item @code{www.reddit.com} is redirected to @code{old.reddit.com}.
 
index 2396e02a3f58fe3050b6a25d85d8772515b87b49..e382432f21b0741eb3bd469309bb375286f1c4bc 100644 (file)
@@ -19,20 +19,15 @@ package rounds
 
 import (
        "net/http"
-       "strings"
 )
 
-func isXombrero(req *http.Request) bool {
-       return strings.Contains(req.Header.Get("User-Agent"), "AppleWebKit/538.15")
-}
-
 func RoundNoHead(
        host string,
        resp *http.Response,
        w http.ResponseWriter,
        req *http.Request,
 ) (bool, error) {
-       if req.Method == http.MethodHead && isXombrero(req) {
+       if req.Method == http.MethodHead {
                http.Error(w, "deny HEAD", http.StatusMethodNotAllowed)
                return false, nil
        }
index 43938ec97672c93a8daf17bb69bed67246f6e673..ff1fd8c7b3c673c0216e4436db6333619c694054 100644 (file)
@@ -25,12 +25,17 @@ import (
        "net/http"
        "os"
        "os/exec"
+       "strings"
 
        "go.stargrave.org/tofuproxy/fifos"
 )
 
 const CmdDWebP = "dwebp"
 
+func isXombrero(req *http.Request) bool {
+       return strings.Contains(req.Header.Get("User-Agent"), "AppleWebKit/538.15")
+}
+
 func RoundTranscodeWebP(
        host string,
        resp *http.Response,