From 973378d610b839bcf4c08b687c962d296e09a54a Mon Sep 17 00:00:00 2001 From: Valture Date: Sun, 5 Nov 2017 19:24:26 +0000 Subject: [PATCH] Prevent UA from being set to golang's default ones Go automatically sets HTTP header `User-Agent' to `Go-http-client/1.1' if it hasn't been set before, which in some cases breaks the transparency of proxy. Such behavior can be prevented by setting it to an empty string. --- proxy/http/server.go | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/proxy/http/server.go b/proxy/http/server.go index 6ed20e608..01d4d74d4 100644 --- a/proxy/http/server.go +++ b/proxy/http/server.go @@ -212,6 +212,11 @@ func StripHopByHopHeaders(header http.Header) { for _, h := range strings.Split(connections, ",") { header.Del(strings.TrimSpace(h)) } + + // Prevent UA from being set to golang's default ones + if len(header.Get("User-Agent")) == 0 { + header.Set("User-Agent", "") + } } var errWaitAnother = newError("keep alive")