From e7376aca25d9d4500162d4089363afa6b0fe8262 Mon Sep 17 00:00:00 2001 From: Brad Fitzpatrick Date: Sat, 10 Sep 2022 08:43:18 -0700 Subject: [PATCH] net/dns/resolver: set DNS-over-HTTPS Accept and User-Agent header on requests Change-Id: I14b821771681e70405a507f43229c694159265ff Signed-off-by: Brad Fitzpatrick --- net/dns/resolver/forwarder.go | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/net/dns/resolver/forwarder.go b/net/dns/resolver/forwarder.go index 41534c7c4..8e1b5ba0b 100644 --- a/net/dns/resolver/forwarder.go +++ b/net/dns/resolver/forwarder.go @@ -37,6 +37,7 @@ "tailscale.com/types/nettype" "tailscale.com/util/cloudenv" "tailscale.com/util/dnsname" + "tailscale.com/version" "tailscale.com/wgengine/monitor" ) @@ -459,11 +460,8 @@ func (f *forwarder) sendDoH(ctx context.Context, urlBase string, c *http.Client, return nil, err } req.Header.Set("Content-Type", dohType) - // Note: we don't currently set the Accept header (which is - // only a SHOULD in the spec) as iOS doesn't use HTTP/2 and - // we'd rather save a few bytes on outgoing requests when - // empirically no provider cares about the Accept header's - // absence. + req.Header.Set("Accept", dohType) + req.Header.Set("User-Agent", "tailscaled/"+version.Long) hres, err := c.Do(req) if err != nil {