Skip to content
This repository has been archived by the owner on Apr 18, 2021. It is now read-only.

Improper use of net/http.Header.Set #2

Closed
tgulacsi opened this issue Oct 24, 2016 · 1 comment
Closed

Improper use of net/http.Header.Set #2

tgulacsi opened this issue Oct 24, 2016 · 1 comment

Comments

@tgulacsi
Copy link

https://github.com/nicolasazrak/caddy-cache/blob/master/cache.go#L25 uses Header.Set to add individual header values, but uses https://godoc.org/pkg/net/http/#Header.Set, which replaces all values with this one - this is wrong.

I'd use

    m := w.Header()
    for k, values := range response.HeaderMap {
        m[k] = append(m[k][:0], v...)
    }
@nicolasazrak
Copy link
Owner

Thanks it's fixed now in 25084ff I've used headers.Add() which internally do exactly the same.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants