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

net/http: header.WriteSubset is case sensitive #34918

empijei opened this issue Oct 15, 2019 · 2 comments

net/http: header.WriteSubset is case sensitive #34918

empijei opened this issue Oct 15, 2019 · 2 comments


Copy link

@empijei empijei commented Oct 15, 2019

What version of Go are you using (go version)?

$ go version
go version devel +0e015e20cf Wed Sep 11 12:26:35 2019 +0000 linux/amd64

Does this issue reproduce with the latest release?


What operating system and processor architecture are you using (go env)?

Not relevant

What did you do?

	h := http.Header{}
	exclude := map[string]bool{}
	for k, v := range headers {
		h.Add(k, v)
		exclude[k] = true
	h.WriteSubset(os.Stdout, exclude)

What did you expect to see?


What did you see instead?

All lowercase headers


I think this should either be documented or fixed as WriteSubset is the only method for http.Header that does not perform canonicalization.

/cc @bradfitz @rsc as per
/cc @kele as we found this together

@empijei empijei changed the title net/http: WriteSubset is case sensitive net/http: header.WriteSubset is case sensitive Oct 15, 2019
Copy link

@bradfitz bradfitz commented Oct 15, 2019

WriteSubset is so weird. Unfortunate that we had to export it.

I guess we can document it, but the existing docs are pretty clear:

If exclude is not nil, keys where exclude[key] == true are not written.

A map lookup is never case insensitive.

@bradfitz bradfitz added this to the Unplanned milestone Oct 15, 2019
Copy link

@gopherbot gopherbot commented Oct 16, 2019

Change mentions this issue: net/http: clarify header.WriteSubset behavior

@gopherbot gopherbot closed this in a570fcf Nov 1, 2019
@golang golang locked and limited conversation to collaborators Oct 31, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
4 participants