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

@henrycjchen henrycjchen commented Jul 24, 2020

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

@davecheney davecheney commented Jul 24, 2020

Why not use http.NewRequest?

@henrycjchen
Copy link
Author

@henrycjchen henrycjchen commented Jul 24, 2020

Thanks for reminding, it should work.

@mdlayher
Copy link
Member

@mdlayher mdlayher commented Jul 24, 2020

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

@mdlayher mdlayher closed this Jul 24, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
3 participants
You can’t perform that action at this time.