Example usage for org.apache.http.cookie ClientCookie DISCARD_ATTR

List of usage examples for org.apache.http.cookie ClientCookie DISCARD_ATTR

Introduction

In this page you can find the example usage for org.apache.http.cookie ClientCookie DISCARD_ATTR.

Prototype

String DISCARD_ATTR

To view the source code for org.apache.http.cookie ClientCookie DISCARD_ATTR.

Click Source Link

Usage

From source file:com.github.tmyroadctfig.icloud4j.json.SerializableClientCookie.java

public SerializableClientCookie(Cookie cookie) {
    this.name = cookie.getName();
    this.value = cookie.getValue();
    this.cookieComment = cookie.getComment();
    this.cookieDomain = cookie.getDomain();
    this.cookieExpiryDate = cookie.getExpiryDate() != null ? cookie.getExpiryDate().getTime() : null;
    this.cookiePath = cookie.getPath();
    this.isSecure = cookie.isSecure();
    this.cookieVersion = cookie.getVersion();

    if (cookie instanceof ClientCookie) {
        ClientCookie c = (ClientCookie) cookie;
        copyAttribute(ClientCookie.COMMENT_ATTR, c);
        copyAttribute(ClientCookie.COMMENTURL_ATTR, c);
        copyAttribute(ClientCookie.DISCARD_ATTR, c);
        copyAttribute(ClientCookie.DOMAIN_ATTR, c);
        copyAttribute(ClientCookie.EXPIRES_ATTR, c);
        copyAttribute(ClientCookie.MAX_AGE_ATTR, c);
        copyAttribute(ClientCookie.PATH_ATTR, c);
        copyAttribute(ClientCookie.PORT_ATTR, c);
        copyAttribute(ClientCookie.SECURE_ATTR, c);
        copyAttribute(ClientCookie.DOMAIN_ATTR, c);
    }/*from w  w w. j a va  2s .  c  o m*/
}

From source file:org.esxx.js.protocol.CookieJar.java

private Scriptable cookieToScriptable(Context cx, Cookie cookie) {
    Scriptable js = cx.newObject(jsuri);
    Scriptable raw = cx.newObject(js);/* w w w  .  ja v  a  2s  . co  m*/

    js.put("raw", js, raw);

    setValue(cx, cookie, js, raw, "name", cookie.getName());
    setValue(cx, cookie, js, raw, "value", cookie.getValue());

    setValue(cx, cookie, js, raw, ClientCookie.COMMENT_ATTR, cookie.getComment());
    setValue(cx, cookie, js, raw, ClientCookie.COMMENTURL_ATTR, cookie.getCommentURL());
    setValue(cx, cookie, js, raw, ClientCookie.DISCARD_ATTR, null);
    setValue(cx, cookie, js, raw, ClientCookie.DOMAIN_ATTR, cookie.getDomain());
    setValue(cx, cookie, js, raw, ClientCookie.EXPIRES_ATTR, cookie.getExpiryDate());
    setValue(cx, cookie, js, raw, ClientCookie.MAX_AGE_ATTR, null);
    setValue(cx, cookie, js, raw, ClientCookie.PATH_ATTR, cookie.getPath());
    setValue(cx, cookie, js, raw, ClientCookie.PORT_ATTR, cookie.getPorts());
    setValue(cx, cookie, js, raw, ClientCookie.SECURE_ATTR, cookie.isSecure());
    setValue(cx, cookie, js, raw, ClientCookie.VERSION_ATTR, cookie.getVersion());

    return js;
}

From source file:org.esxx.js.protocol.CookieJar.java

private Cookie scriptableToCookie(Context cx, Scriptable js) {
    String name = Context.toString(js.get("name", js));
    String value = Context.toString(js.get("value", js));
    Object raw = js.get("raw", js);

    BasicClientCookie cookie;/*w  w w  .j  av a 2  s  .  c  o m*/

    if (js.has(ClientCookie.COMMENTURL_ATTR, js) || js.has(ClientCookie.DISCARD_ATTR, js)
            || js.has(ClientCookie.PORT_ATTR, js)) {
        BasicClientCookie2 cookie2 = new BasicClientCookie2(name, value);

        cookie2.setCommentURL(stringValue(cx, js, raw, cookie2, ClientCookie.COMMENTURL_ATTR));
        cookie2.setDiscard(booleanValue(cx, js, raw, cookie2, ClientCookie.DISCARD_ATTR));
        cookie2.setPorts(intArrayValue(cx, js, raw, cookie2, ClientCookie.PORT_ATTR));
        cookie = cookie2;
    } else {
        cookie = new BasicClientCookie(name, value);
    }

    cookie.setComment(stringValue(cx, js, raw, cookie, ClientCookie.COMMENT_ATTR));
    cookie.setDomain(stringValue(cx, js, raw, cookie, ClientCookie.DOMAIN_ATTR));
    cookie.setExpiryDate(dateValue(cx, js, raw, cookie, ClientCookie.EXPIRES_ATTR));
    cookie.setPath(stringValue(cx, js, raw, cookie, ClientCookie.PATH_ATTR));
    cookie.setSecure(booleanValue(cx, js, raw, cookie, ClientCookie.SECURE_ATTR));
    cookie.setVersion(intValue(cx, js, raw, cookie, ClientCookie.VERSION_ATTR));

    setRawValue(raw, cookie, ClientCookie.MAX_AGE_ATTR);

    return cookie;
}