Example usage for org.apache.commons.httpclient Cookie setVersion

List of usage examples for org.apache.commons.httpclient Cookie setVersion

Introduction

In this page you can find the example usage for org.apache.commons.httpclient Cookie setVersion.

Prototype

public void setVersion(int paramInt) 

Source Link

Usage

From source file:org.mule.transport.http.CookieHelper.java

/**
 * Transforms a {@link ServerCookie} (from Apache Tomcat) into a {@link Cookie}
 * (from commons httpclient). Both types of Cookie hold the same data but the
 * {@link ServerCookie} is the type that you get when parsing cookies as a
 * Server./*from  w ww  .ja v  a2  s  .  c  o  m*/
 */
protected static Cookie transformServerCookieToClientCookie(ServerCookie serverCookie) {
    Cookie clientCookie = new Cookie(serverCookie.getDomain().toString(), serverCookie.getName().toString(),
            serverCookie.getValue().toString(), serverCookie.getPath().toString(), serverCookie.getMaxAge(),
            serverCookie.getSecure());
    clientCookie.setComment(serverCookie.getComment().toString());
    clientCookie.setVersion(serverCookie.getVersion());
    return clientCookie;
}

From source file:org.mule.transport.http.CookieWrapper.java

public Cookie createCookie() throws ParseException {
    Cookie cookie = new Cookie();
    cookie.setName(getName());//w  w  w .  j a va 2  s  .  com
    cookie.setValue(getValue());
    cookie.setDomain(domain);
    cookie.setPath(path);

    if (expiryDate != null) {
        cookie.setExpiryDate(formatExpiryDate(expiryDate));
    }

    if (maxAge != null && expiryDate == null) {
        cookie.setExpiryDate(new Date(System.currentTimeMillis() + Integer.valueOf(maxAge) * 1000L));
    }

    if (secure != null) {
        cookie.setSecure(Boolean.valueOf(secure));
    }
    if (version != null) {
        cookie.setVersion(Integer.valueOf(version));
    }

    return cookie;
}

From source file:org.zaproxy.zap.network.ZapCookieSpecUnitTest.java

@Test(expected = MalformedCookieException.class)
public void shouldBeMalformedWhenValidatingWithNegativeCookieVersion() throws MalformedCookieException {
    // Given/*from ww w.  j a  v  a 2  s.c  o m*/
    CookieSpec cookieSpec = createCookieSpec();
    Cookie cookie = new Cookie(HOST, "name", "value");
    cookie.setVersion(-1);
    // When
    cookieSpec.validate(HOST, PORT, PATH, SECURE, cookie);
    // Then = MalformedCookieException.
}