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

Closed
empijei opened this issue Oct 15, 2019 · 2 comments
Closed

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

empijei opened this issue Oct 15, 2019 · 2 comments

Comments

@empijei
Copy link
Contributor

@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?

Yes

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

Not relevant

What did you do?

https://play.golang.org/p/gtm6ZUm4omF

	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?

Nothing

What did you see instead?

All lowercase headers

Notes

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 https://dev.golang.org/owners
/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
@bradfitz

This comment has been minimized.

Copy link
Member

@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
@gopherbot

This comment has been minimized.

Copy link

@gopherbot gopherbot commented Oct 16, 2019

Change https://golang.org/cl/201357 mentions this issue: net/http: clarify header.WriteSubset behavior

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
4 participants
You can’t perform that action at this time.