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

module net/http/request addCookie error #40383

Closed
henrycjchen opened this issue Jul 24, 2020 · 3 comments
Closed

module net/http/request addCookie error #40383

henrycjchen opened this issue Jul 24, 2020 · 3 comments

Comments

@henrycjchen
Copy link

When I init a request without a header, it will cause a error if I use AddCookie

req := http.Request{}
req.AddCookie(&http.Cookie{
	Name: "access_token",
	Value: "123",
})
// assignment to entry in nil map 

Should method AddCookie check the header and init it, or the coder init the header before use AddCookie?
(relevant code:

r.Header.Set("Cookie", c+"; "+s)
)
PTAL.

@davecheney
Copy link
Contributor

Why not use http.NewRequest?

@henrycjchen
Copy link
Author

Thanks for reminding, it should work.

@mdlayher
Copy link
Member

See also https://github.com/golang/go/wiki/Questions. Looks like this is resolved, closing.

@golang golang locked and limited conversation to collaborators Jul 24, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

4 participants