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.Clone behavior #33141

Closed
dsnet opened this issue Jul 16, 2019 · 3 comments
Closed

net/http: Header.Clone behavior #33141

dsnet opened this issue Jul 16, 2019 · 3 comments
Labels
FrozenDueToAge NeedsDecision Feedback is required from experts, contributors, and/or the community before a change can be made. release-blocker
Milestone

Comments

@dsnet
Copy link
Member

dsnet commented Jul 16, 2019

The Header.Clone method is being added in Go1.13. It's current behavior is to always allocate a map and return it even if the receiver is nil.

Thus:

h1 := http.Header(nil)
h2 := h1.Clone()
fmt.Println(h1 == nil) // true
fmt.Println(h2 == nil) // false

Is this behavior we want to go with? It seems more consistent for Clone to return nil if the receiver is also nil.

@dsnet dsnet added this to the Go1.13 milestone Jul 16, 2019
@dsnet dsnet changed the title net/http: Request.Clone behavior net/http: Header.Clone behavior Jul 17, 2019
@dsnet dsnet added NeedsDecision Feedback is required from experts, contributors, and/or the community before a change can be made. release-blocker labels Jul 17, 2019
@golang golang deleted a comment from gopherbot Jul 17, 2019
@andybons
Copy link
Member

Agree. Will send a change.

@bsiegert

@gopherbot
Copy link

Change https://golang.org/cl/188022 mentions this issue: net/http: return nil from Header.Clone if the receiver is nil

@odeke-em
Copy link
Member

Good catch @dsnet! I agree that passing a nil header to Clone should also return a nil header and I'll review @andybons' CL

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
FrozenDueToAge NeedsDecision Feedback is required from experts, contributors, and/or the community before a change can be made. release-blocker
Projects
None yet
Development

No branches or pull requests

4 participants