Notification for rejected cookies
Categories
(Core :: Networking: Cookies, enhancement, P3)
Tracking
()
Tracking | Status | |
---|---|---|
firefox76 | --- | fixed |
People
(Reporter: Honza, Assigned: mbansal, Mentored)
References
(Blocks 2 open bugs)
Details
(Keywords: good-first-bug, Whiteboard: [necko-triaged])
Attachments
(1 file)
This is a follow up for bug 1437057
See also this comment
https://bugzilla.mozilla.org/show_bug.cgi?id=1437057#c8
http-on-response-set-cookie
is notified when we process the HTTP Set-Cookie header
It would be great to have a notification when one of those cookies is rejected.
Honza
This bug should change this code in the following way:
NotifySetCookie should take another parameter like bool aSuccess
.
We'd change the call to NotifySetCookie(aCookieHeader, NS_SUCCEEDED(rv));
Depending on the value of aSuccess, we'd either pass "http-on-response-set-cookie" or "http-on-response-failed-set-cookie" to NotifyObservers.
hey @Valentin
It seems I need to make these changes and it should work
void HttpBaseChannel::NotifySetCookie(const nsACString& aCookie, bool aSuccess) {
nsCOMPtr<nsIObserverService> obs = services::GetObserverService();
if (obs) {
nsAutoString cookie;
if(aSuccess)
{
obs->NotifyObservers(static_cast<nsIChannel*>(this),
"http-on-response-set-cookie",
NS_ConvertASCIItoUTF16(aCookie).get());
}
else
{
obs->NotifyObservers(static_cast<nsIChannel*>(this),
"http-on-response-failed-set-cookie",
NS_ConvertASCIItoUTF16(aCookie).get());
}
}
}
Reporter | ||
Comment 4•5 years ago
|
||
Btw. there is an existing cookie-rejected
observer notification:
https://developer.mozilla.org/en-US/docs/Mozilla/Tech/XPCOM/Observer_Notifications
How's that suppose to work with the new API suggested here?
Honza
Comment 5•5 years ago
|
||
Can we please wait until bug 1624146 lands? I'm in the middle of an important code refactoring and this feature can be easily implemented on top of it.
Hey @Andrea Marchesini !!
How much time will it take ?
And @honza Could you please elaborate me on this cookie-rejected
notifications ?
I don't have any idea how it will work with my idea :)
Thanks
(In reply to Jan Honza Odvarko [:Honza] (always need-info? me) from comment #4)
Btw. there is an existing
cookie-rejected
observer notification:
https://developer.mozilla.org/en-US/docs/Mozilla/Tech/XPCOM/Observer_NotificationsHow's that suppose to work with the new API suggested here?
You're right it seems to me like that notification is already sent
Moreover, since nsCookieService::SetCookieStringCommon only returns NS_OK, this approach wouldn't work.
In any case, it seems the only case where we wouldn't send the notification is this when we use ftp or have no principal do you need a notification for those cases too?
Reporter | ||
Comment 8•5 years ago
|
||
(In reply to Valentin Gosu [:valentin] (he/him) from comment #7)
In any case, it seems the only case where we wouldn't send the notification is this when we use ftp or have no principal do you need a notification for those cases too?
Yes, we want to know about all rejected cookies.
Thanks Valentin!
Honza
Updated•5 years ago
|
Updated•5 years ago
|
Comment 10•5 years ago
|
||
Comment 11•5 years ago
|
||
bugherder |
Reporter | ||
Updated•5 years ago
|
Description
•