Skip to content

Multiple same-name Headers are ignored #643

@klaus

Description

@klaus

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))

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions