diff --git a/imageproxy.go b/imageproxy.go index 02c07e8..b304ea1 100644 --- a/imageproxy.go +++ b/imageproxy.go @@ -273,17 +273,11 @@ func peekContentType(p *bufio.Reader) string { return http.DetectContentType(byt) } -// copyHeader copies header values from src to dst, adding to any existing -// values with the same header name. If keys is not empty, only those header -// keys will be copied. -func copyHeader(dst, src http.Header, keys ...string) { - if len(keys) == 0 { - for k := range src { - keys = append(keys, k) - } - } - for _, key := range keys { - k := http.CanonicalHeaderKey(key) +// copyHeader copies values for specified headers from src to dst, adding to +// any existing values with the same header name. +func copyHeader(dst, src http.Header, headerNames ...string) { + for _, name := range headerNames { + k := http.CanonicalHeaderKey(name) for _, v := range src[k] { dst.Add(k, v) } diff --git a/imageproxy_test.go b/imageproxy_test.go index c2d4b82..87c2f5d 100644 --- a/imageproxy_test.go +++ b/imageproxy_test.go @@ -62,30 +62,12 @@ func TestCopyHeader(t *testing.T) { }, // copy headers - { - dst: http.Header{}, - src: http.Header{"A": []string{"a"}}, - keys: nil, - want: http.Header{"A": []string{"a"}}, - }, - { - dst: http.Header{"A": []string{"a"}}, - src: http.Header{"B": []string{"b"}}, - keys: nil, - want: http.Header{"A": []string{"a"}, "B": []string{"b"}}, - }, { dst: http.Header{"A": []string{"a"}}, src: http.Header{"B": []string{"b"}, "C": []string{"c"}}, keys: []string{"B"}, want: http.Header{"A": []string{"a"}, "B": []string{"b"}}, }, - { - dst: http.Header{"A": []string{"a1"}}, - src: http.Header{"A": []string{"a2"}}, - keys: nil, - want: http.Header{"A": []string{"a1", "a2"}}, - }, } for _, tt := range tests {