PacktPublishing / Hands-On-Restful-Web-services-with-Go

Hands-On Restful Web services with Go by Packt Publishing
MIT License
107 stars 73 forks source link

set cookie before header map is sent #28

Closed epicavic closed 3 years ago

epicavic commented 3 years ago

$ go version go version go1.15.8 darwin/amd64

1) http.SetCookie will silently drop the cookie header if name contains not allowed characters (parens in this case) https://golang.org/pkg/net/http/#SetCookie https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Set-Cookie

2) calling original handler before writing cookie would silently drop the cookie since header map has been already sent to user https://golang.org/pkg/net/http/#ResponseWriter https://golang.org/pkg/net/http/#ResponseWriter