From e9dde230247ec5525d4c3803ff99c97e0dc8e348 Mon Sep 17 00:00:00 2001 From: Francis Lavoie Date: Tue, 4 Jan 2022 12:10:11 -0500 Subject: headers: Fix `+` in Caddyfile to properly append rather than set (#4506) --- caddytest/integration/caddyfile_adapt/header.txt | 15 +++++++++++++++ modules/caddyhttp/headers/caddyfile.go | 2 +- 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/caddytest/integration/caddyfile_adapt/header.txt b/caddytest/integration/caddyfile_adapt/header.txt index 223839e..34a044d 100644 --- a/caddytest/integration/caddyfile_adapt/header.txt +++ b/caddytest/integration/caddyfile_adapt/header.txt @@ -13,6 +13,10 @@ header @images { Cache-Control "public, max-age=3600, stale-while-revalidate=86400" } + header { + +Link "Foo" + +Link "Bar" + } } ---------- { @@ -121,6 +125,17 @@ ] } } + }, + { + "handler": "headers", + "response": { + "add": { + "Link": [ + "Foo", + "Bar" + ] + } + } } ] } diff --git a/modules/caddyhttp/headers/caddyfile.go b/modules/caddyhttp/headers/caddyfile.go index c6ea2fb..eec1149 100644 --- a/modules/caddyhttp/headers/caddyfile.go +++ b/modules/caddyhttp/headers/caddyfile.go @@ -222,7 +222,7 @@ func applyHeaderOp(ops *HeaderOps, respHeaderOps *RespHeaderOps, field, value, r if ops.Add == nil { ops.Add = make(http.Header) } - ops.Add.Set(field[1:], value) + ops.Add.Add(field[1:], value) case strings.HasPrefix(field, "-"): // delete ops.Delete = append(ops.Delete, field[1:]) -- cgit v1.2.3