Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Multiple same-name Headers are ignored #643

Closed
klaus opened this issue Dec 15, 2017 · 2 comments
Closed

Multiple same-name Headers are ignored #643

klaus opened this issue Dec 15, 2017 · 2 comments

Comments

@klaus
Copy link
Contributor

klaus commented Dec 15, 2017

In transport/http/server.go i have found 2 places where the headers are not correctly set to all values the http.Header might be holding.

http.Header is a map[string][]string and .Get(k) only returns the first of those fields from the []string array. I think to correctly handle it, we should do as the docs suggest:

// Get gets the first value associated with the given key.
// It is case insensitive; textproto.CanonicalMIMEHeaderKey is used
// to canonicalize the provided key.
// If there are no values associated with the key, Get returns "".
// To access multiple values of a key, or to use non-canonical keys,
// access the map directly.
func (h Header) Get(key string) string {
	return textproto.MIMEHeader(h).Get(key)
}

which would be sthg along the lines ...

		for k,hdrs := range headerer.Headers() {
			for _,h := range hdrs {
                             w.Header().Add(k, h))
                        }
		}

w.Header().Set(k, headerer.Headers().Get(k))

@peterbourgon
Copy link
Member

Yes, fully agreed. An easy fix, where's the PR? ;)

@klaus
Copy link
Contributor Author

klaus commented Dec 18, 2017

#644, sorry, weekends are busy, so are weekdays, but this weekend was very busy ;)

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

No branches or pull requests

2 participants