jetty-server/src/main/java/org/eclipse/jetty/server/Response.java
/**
     * Replace (or add) a cookie.
     * Using name, path and domain, look for a matching set-cookie header and replace it.
     *
     * @param cookie The cookie to add/replace
     */
Replace (or add) a cookie.
Using name, path and domain, look for a matching set-cookie header and replace it.

@param cookie The cookie to add/replace
Replace ( or add ) a cookie . Using name path and domain look for a matching set - cookie header and replace it . @param cookie The cookie to add / replace
public void replaceCookie(HttpCookie cookie)
    {
        for (ListIterator<HttpField> i = _fields.listIterator(); i.hasNext(); )
        {
            HttpField field = i.next();
            if (field.getHeader() == HttpHeader.SET_COOKIE)
            {
                CookieCompliance compliance = getHttpChannel().getHttpConfiguration().getResponseCookieCompliance();
                HttpCookie oldCookie;
                if (field instanceof SetCookieHttpField)
                    oldCookie = ((SetCookieHttpField)field).getHttpCookie();
                else
                    oldCookie = new HttpCookie(field.getValue());
                if (!cookie.getName().equals(oldCookie.getName()))
                    continue;
                if (cookie.getDomain() == null)
                {
                    if (oldCookie.getDomain() != null)
                        continue;
                }
                else if (!cookie.getDomain().equalsIgnoreCase(oldCookie.getDomain()))
                    continue;
                if (cookie.getPath() == null)
                {
                    if (oldCookie.getPath() != null)
                        continue;
                }
                else if (!cookie.getPath().equals(oldCookie.getPath()))
                    continue;
                i.set(new SetCookieHttpField(cookie, compliance));
                return;
            }
        }
        addCookie(cookie);
    }
public void replaceCookie ( HttpCookie cookie ) { for ( ListIterator < HttpField > i = _fields . listIterator ( ) ; i . hasNext ( ) ; ) { HttpField field = i . next ( ) ; if ( field . getHeader ( ) == HttpHeader . SET_COOKIE ) { CookieCompliance compliance = getHttpChannel ( ) . getHttpConfiguration ( ) . getResponseCookieCompliance ( ) ; HttpCookie oldCookie ; if ( field instanceof SetCookieHttpField ) oldCookie = ( ( SetCookieHttpField ) field ) . getHttpCookie ( ) ; else oldCookie = new HttpCookie ( field . getValue ( ) ) ; if ( ! cookie . getName ( ) . equals ( oldCookie . getName ( ) ) ) continue ; if ( cookie . getDomain ( ) == null ) { if ( oldCookie . getDomain ( ) != null ) continue ; } else if ( ! cookie . getDomain ( ) . equalsIgnoreCase ( oldCookie . getDomain ( ) ) ) continue ; if ( cookie . getPath ( ) == null ) { if ( oldCookie . getPath ( ) != null ) continue ; } else if ( ! cookie . getPath ( ) . equals ( oldCookie . getPath ( ) ) ) continue ; i . set ( new SetCookieHttpField ( cookie , compliance ) ) ; return ; } } addCookie ( cookie ) ; }
Replace (or add) a cookie.
Replace ( or add ) a cookie .
// Not replaced, so add normally