From: Sergey Matveev <stargrave@stargrave.org>
Date: Tue, 7 Sep 2021 21:51:02 +0000 (+0300)
Subject: Xombrero does not send User-Agent with HEAD
X-Git-Tag: v0.1.0~78
X-Git-Url: http://www.git.stargrave.org/?a=commitdiff_plain;h=de174016b8d0a6dadde991a1f265f75bd86d52fc;p=tofuproxy.git

Xombrero does not send User-Agent with HEAD
---

diff --git a/doc/index.texi b/doc/index.texi
index 0d27a68..7759710 100644
--- a/doc/index.texi
+++ b/doc/index.texi
@@ -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}.
 
diff --git a/rounds/05noHead.go b/rounds/05noHead.go
index 2396e02..e382432 100644
--- a/rounds/05noHead.go
+++ b/rounds/05noHead.go
@@ -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
 	}
diff --git a/rounds/40transcodeWebP.go b/rounds/40transcodeWebP.go
index 43938ec..ff1fd8c 100644
--- a/rounds/40transcodeWebP.go
+++ b/rounds/40transcodeWebP.go
@@ -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,