-
Notifications
You must be signed in to change notification settings - Fork 18k
net/http/cookiejar: cookie names containing underscore prefix cannot be manipulated #24527
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
Comments
@qZanity Can you show us some code? |
/cc @vdobler too |
I cannot reproduce the problem. See https://play.golang.org/p/U6l6-5T54ds @qZanity Maybe the underlying case of the problem you experience is not in the cookiejar but somewhere else? And maybe you could clarify what exactly you mean with
Note that From my point of view it works as intended. |
Thanks to everyone acting quickly on this. @vdobler I checked your snippet and yes no issues there. But check this: https://play.golang.org/p/7VP-SKwUlO5 This is a simple implementation using CookieJar with http.Client. You can see that after I SetCookie() a duplicate cookie is created and sent in the next request. I can't get my ahead around why this is happening? To me it looks like a bug, But its seems to be site specific. My development server is local, so I've used Adidas as an example here and it behaves the same way. Cheers. |
The sample helped. www.adidas.co.uk;/;_abck":cookiejar.entry{Name:"_abck", Value:"test", |
No, sorry this is not a bug. You have been tripped by a common misunderstanding regarding the The following explanation is not correct in each and every While the name is always given explicitly the path and domain of If you just do a SetCookie with a different domain (in your case To fix you atempt to modifiy a cookie in the jar you have to
But pay attention: This would not only update the Value of the The result of Cookie() with several cookies with the same name So it's not a bug, Jar works as required by RFC 6265 (which is |
What version of Go are you using (
go version
)?go version go1.8.1 windows/amd64
Does this issue reproduce with the latest release?
Yes.
What operating system and processor architecture are you using (
go env
)?What did you do?
When using the http cookiejar, you cannot manipulate cookies that start with a underscore in the cookie names. If you attempt to change the cookie value, it just sets a duplicate cookie and does not change the original value. You also cannot delete these cookies using any of the known methods.
For example a cookie called "_myCookie" cannot be manipulated programmatically using *func (Jar) Cookies however, the cookiejar does handle the cookies automatically.
What did you expect to see?
Expected cookie value to change or cookie to be deleted.
What did you see instead?
Duplicate cookie with same name.
The text was updated successfully, but these errors were encountered: