franmontiel/PersistentCookieJar

About some of IdentifiableCookie

Closed this issue · 2 comments

Hi~
PersistentCookieJar is helpful for me!
But once I found my request to get three cookie, save only the results of the two, both the cookie value is not the same, I find IdentifiableCookie:

 @Override
    public boolean equals(Object other) {
        if (!(other instanceof IdentifiableCookie)) return false;
        IdentifiableCookie that = (IdentifiableCookie) other;
        return that.cookie.name().equals(this.cookie.name())
                && that.cookie.domain().equals(this.cookie.domain())
                && that.cookie.path().equals(this.cookie.path())
                && that.cookie.secure() == this.cookie.secure()
                && that.cookie.hostOnly() == this.cookie.hostOnly();
    }

In okhttp3 the cookie inside the class methods:

@Override public boolean equals(Object other) {
    if (!(other instanceof Cookie)) return false;
    Cookie that = (Cookie) other;
    return that.name.equals(name)
        && that.value.equals(value)
        && that.domain.equals(domain)
        && that.path.equals(path)
        && that.expiresAt == expiresAt
        && that.secure == secure
        && that.httpOnly == httpOnly
        && that.persistent == persistent
        && that.hostOnly == hostOnly;
  }

I do not know which is better~
Thanks.

According to the this section of the RFC 6265 (paragraph 11) if we receive a cookie with the same name, path and domain that one of our stored cookies we should update the old one.
The equals implementation provided by the okhttp3 Cookie correct to check if two Cookies are (exactly) the same but it does not fit the storage policy.

Thanks a lot!