From ca6317b2fc85beeba4517f9d50851d1134b34b39 Mon Sep 17 00:00:00 2001 From: Francis Lavoie Date: Tue, 22 Oct 2024 11:38:49 -0400 Subject: Use clear() https://github.com/golang/go/commit/3bc28402fae2a1646e4d2756344b5eb34994d25f --- modules/caddyhttp/headers/headers.go | 4 +--- modules/caddyhttp/reverseproxy/reverseproxy.go | 4 +--- 2 files changed, 2 insertions(+), 6 deletions(-) diff --git a/modules/caddyhttp/headers/headers.go b/modules/caddyhttp/headers/headers.go index a3279d913..c66bd4144 100644 --- a/modules/caddyhttp/headers/headers.go +++ b/modules/caddyhttp/headers/headers.go @@ -200,9 +200,7 @@ func (ops HeaderOps) ApplyTo(hdr http.Header, repl *caddy.Replacer) { for _, fieldName := range ops.Delete { fieldName = repl.ReplaceKnown(fieldName, "") if fieldName == "*" { - for existingField := range hdr { - delete(hdr, existingField) - } + clear(hdr) } } diff --git a/modules/caddyhttp/reverseproxy/reverseproxy.go b/modules/caddyhttp/reverseproxy/reverseproxy.go index a32994e04..1250eae6c 100644 --- a/modules/caddyhttp/reverseproxy/reverseproxy.go +++ b/modules/caddyhttp/reverseproxy/reverseproxy.go @@ -826,9 +826,7 @@ func (h *Handler) reverseProxy(rw http.ResponseWriter, req *http.Request, origRe // Clear headers coming from the backend // (it's not automatically done by ResponseWriter.WriteHeader() for 1xx responses) - for k := range header { - delete(h, k) - } + clear(h) return nil }, -- cgit v1.2.3