-
Notifications
You must be signed in to change notification settings - Fork 17.7k
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: add ParseCookie, ParseSetCookie #66008
Comments
There is a longstanding issue #46443 (net/http: implementation of cookies does not conform to RFC 6265 for double-quoted values) on what exactly is the "value" of a cookie sent like net/http always stripped the double quotes from the value, so By adding ParseCookie (and probably ParseSetCookie) using just the current implementation we would fix that behaviour even more. Maybe this proposal should address on how to distinguish It seems plausible to me that ParseCookie and ParseSetCookie might be useful to "manually" distinguish That said I still think adding a new boolean field net/http.Cookie.DoubleQuoted might solve #46443 and might be worth adding to this proposal. |
This proposal has been added to the active column of the proposals project |
It's good we didn't actually do #25194, since that API looks wrong anyway. What is the API we want here? I assume we want net/http to be able to use these routines itself, or some common implementation at least. The implementations in net/http are:
If we provided
I see at least the following implications:
We can work around all of these, as noted, but it does mean that you can't use ParseCookie/ParseSetCookie to get all the speed that net/http does. Is that fine? Probably it is? |
Should Without iterators, if we want something that
|
Iterators seems like a little bit of overkill here. For name filtering, internally net/http can get at anything. I'm not sure we need to expose the name filtering for user code. |
Are there real-world use cases that are not well enough handled by:
? |
Have all remaining concerns about this proposal been addressed? The proposal is to add func ParseCookie(line string) ([]*Cookie, error) |
Based on the discussion above, this proposal seems like a likely accept. The proposal is to add func ParseCookie(line string) ([]*Cookie, error) |
No change in consensus, so accepted. 🎉 The proposal is to add func ParseCookie(line string) ([]*Cookie, error) |
Change https://go.dev/cl/578275 mentions this issue: |
Change https://go.dev/cl/579795 mentions this issue: |
Updates #66008 Change-Id: Idd36a7f0b4128adfd0a3d7fe76eb6c2cea4306a3 Reviewed-on: https://go-review.googlesource.com/c/go/+/579795 Reviewed-by: Damien Neil <[email protected]> Reviewed-by: Cherry Mui <[email protected]> LUCI-TryBot-Result: Go LUCI <[email protected]> Auto-Submit: Damien Neil <[email protected]>
Following up on #25194, which was approved in 2018 but only recently implemented, it looks like it makes more sense to add ParseCookie and ParseSetCookie directly to net/http, to avoid significant duplication (specifically of the Cookie type and the parsers) between httpguts and http.
The text was updated successfully, but these errors were encountered: