Closed Bug 1624286 Opened 5 years ago Closed 5 years ago

Notification for rejected cookies

Categories

(Core :: Networking: Cookies, enhancement, P3)

enhancement

Tracking

()

RESOLVED FIXED
mozilla76
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.

Mentor: valentin.gosu
Priority: -- → P3
Whiteboard: [necko-triaged][good first bug]

hey @valentin
Can I work on this ?
thanks :)

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());
}
}
}

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

Flags: needinfo?(valentin.gosu)

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.

Depends on: 1624146

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_Notifications

How'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?

Flags: needinfo?(valentin.gosu) → needinfo?(odvarko)

(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

Flags: needinfo?(odvarko)
Assignee: nobody → mbansal
Status: NEW → ASSIGNED
Keywords: good-first-bug
Whiteboard: [necko-triaged][good first bug] → [necko-triaged]
Status: ASSIGNED → RESOLVED
Closed: 5 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla76
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: