Java 类org.apache.http.cookie.SetCookie 实例源码

项目:lams    文件:RFC2965VersionAttributeHandler.java   
/**
 * Parse cookie version attribute.
 */
public void parse(final SetCookie cookie, final String value)
        throws MalformedCookieException {
    if (cookie == null) {
        throw new IllegalArgumentException("Cookie may not be null");
    }
    if (value == null) {
        throw new MalformedCookieException(
                "Missing value for version attribute");
    }
    int version = -1;
    try {
        version = Integer.parseInt(value);
    } catch (NumberFormatException e) {
        version = -1;
    }
    if (version < 0) {
        throw new MalformedCookieException("Invalid cookie version.");
    }
    cookie.setVersion(version);
}
项目:lams    文件:BasicMaxAgeHandler.java   
public void parse(final SetCookie cookie, final String value)
        throws MalformedCookieException {
    if (cookie == null) {
        throw new IllegalArgumentException("Cookie may not be null");
    }
    if (value == null) {
        throw new MalformedCookieException("Missing value for max-age attribute");
    }
    int age;
    try {
        age = Integer.parseInt(value);
    } catch (NumberFormatException e) {
        throw new MalformedCookieException ("Invalid max-age attribute: "
                + value);
    }
    if (age < 0) {
        throw new MalformedCookieException ("Negative max-age attribute: "
                + value);
    }
    cookie.setExpiryDate(new Date(System.currentTimeMillis() + age * 1000L));
}
项目:lams    文件:RFC2965DomainAttributeHandler.java   
/**
 * Parse cookie domain attribute.
 */
public void parse(final SetCookie cookie, String domain)
        throws MalformedCookieException {
    if (cookie == null) {
        throw new IllegalArgumentException("Cookie may not be null");
    }
    if (domain == null) {
        throw new MalformedCookieException(
                "Missing value for domain attribute");
    }
    if (domain.trim().length() == 0) {
        throw new MalformedCookieException(
                "Blank value for domain attribute");
    }
    domain = domain.toLowerCase(Locale.ENGLISH);
    if (!domain.startsWith(".")) {
        // Per RFC 2965 section 3.2.2
        // "... If an explicitly specified value does not start with
        // a dot, the user agent supplies a leading dot ..."
        // That effectively implies that the domain attribute
        // MAY NOT be an IP address of a host name
        domain = '.' + domain;
    }
    cookie.setDomain(domain);
}
项目:lams    文件:RFC2109VersionHandler.java   
public void parse(final SetCookie cookie, final String value)
        throws MalformedCookieException {
    if (cookie == null) {
        throw new IllegalArgumentException("Cookie may not be null");
    }
    if (value == null) {
        throw new MalformedCookieException("Missing value for version attribute");
    }
    if (value.trim().length() == 0) {
        throw new MalformedCookieException("Blank value for version attribute");
    }
    try {
       cookie.setVersion(Integer.parseInt(value));
    } catch (NumberFormatException e) {
        throw new MalformedCookieException("Invalid version: "
            + e.getMessage());
    }
}
项目:remote-files-sync    文件:RFC2965VersionAttributeHandlerHC4.java   
/**
 * Parse cookie version attribute.
 */
public void parse(final SetCookie cookie, final String value)
        throws MalformedCookieException {
    Args.notNull(cookie, "Cookie");
    if (value == null) {
        throw new MalformedCookieException(
                "Missing value for version attribute");
    }
    int version = -1;
    try {
        version = Integer.parseInt(value);
    } catch (final NumberFormatException e) {
        version = -1;
    }
    if (version < 0) {
        throw new MalformedCookieException("Invalid cookie version.");
    }
    cookie.setVersion(version);
}
项目:remote-files-sync    文件:RFC2965DomainAttributeHandlerHC4.java   
/**
 * Parse cookie domain attribute.
 */
public void parse(
        final SetCookie cookie, final String domain) throws MalformedCookieException {
    Args.notNull(cookie, "Cookie");
    if (domain == null) {
        throw new MalformedCookieException(
                "Missing value for domain attribute");
    }
    if (domain.trim().length() == 0) {
        throw new MalformedCookieException(
                "Blank value for domain attribute");
    }
    String s = domain;
    s = s.toLowerCase(Locale.ENGLISH);
    if (!domain.startsWith(".")) {
        // Per RFC 2965 section 3.2.2
        // "... If an explicitly specified value does not start with
        // a dot, the user agent supplies a leading dot ..."
        // That effectively implies that the domain attribute
        // MAY NOT be an IP address of a host name
        s = '.' + s;
    }
    cookie.setDomain(s);
}
项目:remote-files-sync    文件:RFC2109VersionHandlerHC4.java   
public void parse(final SetCookie cookie, final String value)
        throws MalformedCookieException {
    Args.notNull(cookie, "Cookie");
    if (value == null) {
        throw new MalformedCookieException("Missing value for version attribute");
    }
    if (value.trim().length() == 0) {
        throw new MalformedCookieException("Blank value for version attribute");
    }
    try {
       cookie.setVersion(Integer.parseInt(value));
    } catch (final NumberFormatException e) {
        throw new MalformedCookieException("Invalid version: "
            + e.getMessage());
    }
}
项目:remote-files-sync    文件:BasicMaxAgeHandlerHC4.java   
public void parse(final SetCookie cookie, final String value)
        throws MalformedCookieException {
    Args.notNull(cookie, "Cookie");
    if (value == null) {
        throw new MalformedCookieException("Missing value for max-age attribute");
    }
    final int age;
    try {
        age = Integer.parseInt(value);
    } catch (final NumberFormatException e) {
        throw new MalformedCookieException ("Invalid max-age attribute: "
                + value);
    }
    if (age < 0) {
        throw new MalformedCookieException ("Negative max-age attribute: "
                + value);
    }
    cookie.setExpiryDate(new Date(System.currentTimeMillis() + age * 1000L));
}
项目:purecloud-iot    文件:BrowserCompatVersionAttributeHandler.java   
/**
 * Parse cookie version attribute.
 */
@Override
public void parse(final SetCookie cookie, final String value)
        throws MalformedCookieException {
    Args.notNull(cookie, "Cookie");
    if (value == null) {
        throw new MalformedCookieException("Missing value for version attribute");
    }
    int version = 0;
    try {
        version = Integer.parseInt(value);
    } catch (final NumberFormatException e) {
        // Just ignore invalid versions
    }
    cookie.setVersion(version);
}
项目:purecloud-iot    文件:RFC2965VersionAttributeHandler.java   
/**
 * Parse cookie version attribute.
 */
@Override
public void parse(final SetCookie cookie, final String value)
        throws MalformedCookieException {
    Args.notNull(cookie, "Cookie");
    if (value == null) {
        throw new MalformedCookieException(
                "Missing value for version attribute");
    }
    int version = -1;
    try {
        version = Integer.parseInt(value);
    } catch (final NumberFormatException e) {
        version = -1;
    }
    if (version < 0) {
        throw new MalformedCookieException("Invalid cookie version.");
    }
    cookie.setVersion(version);
}
项目:purecloud-iot    文件:BasicMaxAgeHandler.java   
@Override
public void parse(final SetCookie cookie, final String value)
        throws MalformedCookieException {
    Args.notNull(cookie, "Cookie");
    if (value == null) {
        throw new MalformedCookieException("Missing value for 'max-age' attribute");
    }
    final int age;
    try {
        age = Integer.parseInt(value);
    } catch (final NumberFormatException e) {
        throw new MalformedCookieException ("Invalid 'max-age' attribute: "
                + value);
    }
    if (age < 0) {
        throw new MalformedCookieException ("Negative 'max-age' attribute: "
                + value);
    }
    cookie.setExpiryDate(new Date(System.currentTimeMillis() + age * 1000L));
}
项目:purecloud-iot    文件:RFC2965DomainAttributeHandler.java   
/**
 * Parse cookie domain attribute.
 */
@Override
public void parse(
        final SetCookie cookie, final String domain) throws MalformedCookieException {
    Args.notNull(cookie, "Cookie");
    if (domain == null) {
        throw new MalformedCookieException(
                "Missing value for domain attribute");
    }
    if (domain.trim().isEmpty()) {
        throw new MalformedCookieException(
                "Blank value for domain attribute");
    }
    String s = domain;
    s = s.toLowerCase(Locale.ROOT);
    if (!domain.startsWith(".")) {
        // Per RFC 2965 section 3.2.2
        // "... If an explicitly specified value does not start with
        // a dot, the user agent supplies a leading dot ..."
        // That effectively implies that the domain attribute
        // MAY NOT be an IP address of a host name
        s = '.' + s;
    }
    cookie.setDomain(s);
}
项目:purecloud-iot    文件:RFC2109VersionHandler.java   
@Override
public void parse(final SetCookie cookie, final String value)
        throws MalformedCookieException {
    Args.notNull(cookie, "Cookie");
    if (value == null) {
        throw new MalformedCookieException("Missing value for version attribute");
    }
    if (value.trim().isEmpty()) {
        throw new MalformedCookieException("Blank value for version attribute");
    }
    try {
       cookie.setVersion(Integer.parseInt(value));
    } catch (final NumberFormatException e) {
        throw new MalformedCookieException("Invalid version: "
            + e.getMessage());
    }
}
项目:purecloud-iot    文件:BasicDomainHandler.java   
@Override
public void parse(final SetCookie cookie, final String value)
        throws MalformedCookieException {
    Args.notNull(cookie, "Cookie");
    if (TextUtils.isBlank(value)) {
        throw new MalformedCookieException("Blank or null value for domain attribute");
    }
    // Ignore domain attributes ending with '.' per RFC 6265, 4.1.2.3
    if (value.endsWith(".")) {
        return;
    }
    String domain = value;
    if (domain.startsWith(".")) {
        domain = domain.substring(1);
    }
    domain = domain.toLowerCase(Locale.ROOT);
    cookie.setDomain(domain);
}
项目:purecloud-iot    文件:LaxMaxAgeHandler.java   
@Override
public void parse(final SetCookie cookie, final String value) throws MalformedCookieException {
    Args.notNull(cookie, "Cookie");
    if (TextUtils.isBlank(value)) {
        return;
    }
    final Matcher matcher = MAX_AGE_PATTERN.matcher(value);
    if (matcher.matches()) {
        final int age;
        try {
            age = Integer.parseInt(value);
        } catch (final NumberFormatException e) {
            return;
        }
        final Date expiryDate = age >= 0 ? new Date(System.currentTimeMillis() + age * 1000L) :
                new Date(Long.MIN_VALUE);
        cookie.setExpiryDate(expiryDate);
    }
}
项目:purecloud-iot    文件:TestRFC6265CookieSpec.java   
@Test
public void testParseCookieMaxAgeOverExpires() throws Exception {
    final CommonCookieAttributeHandler h1 = Mockito.mock(CommonCookieAttributeHandler.class);
    Mockito.when(h1.getAttributeName()).thenReturn("Expires");
    final CommonCookieAttributeHandler h2 = Mockito.mock(CommonCookieAttributeHandler.class);
    Mockito.when(h2.getAttributeName()).thenReturn("Max-Age");

    final RFC6265CookieSpec cookiespec = new RFC6265CookieSpec(h1, h2);

    final Header header = new BasicHeader("Set-Cookie", "name = value ; expires = stuff; max-age = otherstuff;");
    final CookieOrigin origin = new CookieOrigin("host", 80, "/path/", true);
    cookiespec.parse(header, origin);

    Mockito.verify(h1, Mockito.never()).parse(Mockito.<SetCookie>any(), Mockito.anyString());
    Mockito.verify(h2).parse(Mockito.<SetCookie>any(), Mockito.eq("otherstuff"));
}
项目:Visit    文件:RFC2965VersionAttributeHandlerHC4.java   
/**
 * Parse cookie version attribute.
 */
public void parse(final SetCookie cookie, final String value)
        throws MalformedCookieException {
    Args.notNull(cookie, "Cookie");
    if (value == null) {
        throw new MalformedCookieException(
                "Missing value for version attribute");
    }
    int version = -1;
    try {
        version = Integer.parseInt(value);
    } catch (final NumberFormatException e) {
        version = -1;
    }
    if (version < 0) {
        throw new MalformedCookieException("Invalid cookie version.");
    }
    cookie.setVersion(version);
}
项目:Visit    文件:RFC2965DomainAttributeHandlerHC4.java   
/**
 * Parse cookie domain attribute.
 */
public void parse(
        final SetCookie cookie, final String domain) throws MalformedCookieException {
    Args.notNull(cookie, "Cookie");
    if (domain == null) {
        throw new MalformedCookieException(
                "Missing value for domain attribute");
    }
    if (domain.trim().length() == 0) {
        throw new MalformedCookieException(
                "Blank value for domain attribute");
    }
    String s = domain;
    s = s.toLowerCase(Locale.ENGLISH);
    if (!domain.startsWith(".")) {
        // Per RFC 2965 section 3.2.2
        // "... If an explicitly specified value does not start with
        // a dot, the user agent supplies a leading dot ..."
        // That effectively implies that the domain attribute
        // MAY NOT be an IP address of a host name
        s = '.' + s;
    }
    cookie.setDomain(s);
}
项目:Visit    文件:RFC2109VersionHandlerHC4.java   
public void parse(final SetCookie cookie, final String value)
        throws MalformedCookieException {
    Args.notNull(cookie, "Cookie");
    if (value == null) {
        throw new MalformedCookieException("Missing value for version attribute");
    }
    if (value.trim().length() == 0) {
        throw new MalformedCookieException("Blank value for version attribute");
    }
    try {
       cookie.setVersion(Integer.parseInt(value));
    } catch (final NumberFormatException e) {
        throw new MalformedCookieException("Invalid version: "
            + e.getMessage());
    }
}
项目:Visit    文件:BasicMaxAgeHandlerHC4.java   
public void parse(final SetCookie cookie, final String value)
        throws MalformedCookieException {
    Args.notNull(cookie, "Cookie");
    if (value == null) {
        throw new MalformedCookieException("Missing value for max-age attribute");
    }
    final int age;
    try {
        age = Integer.parseInt(value);
    } catch (final NumberFormatException e) {
        throw new MalformedCookieException ("Invalid max-age attribute: "
                + value);
    }
    if (age < 0) {
        throw new MalformedCookieException ("Negative max-age attribute: "
                + value);
    }
    cookie.setExpiryDate(new Date(System.currentTimeMillis() + age * 1000L));
}
项目:cJUnit-mc626    文件:RFC2965VersionAttributeHandler.java   
/**
 * Parse cookie version attribute.
 */
public void parse(final SetCookie cookie, final String value)
        throws MalformedCookieException {
    if (cookie == null) {
        throw new IllegalArgumentException("Cookie may not be null");
    }
    if (value == null) {
        throw new MalformedCookieException(
                "Missing value for version attribute");
    }
    int version = -1;
    try {
        version = Integer.parseInt(value);
    } catch (NumberFormatException e) {
        version = -1;
    }
    if (version < 0) {
        throw new MalformedCookieException("Invalid cookie version.");
    }
    cookie.setVersion(version);
}
项目:cJUnit-mc626    文件:BasicMaxAgeHandler.java   
public void parse(final SetCookie cookie, final String value) 
        throws MalformedCookieException {
    if (cookie == null) {
        throw new IllegalArgumentException("Cookie may not be null");
    }
    if (value == null) {
        throw new MalformedCookieException("Missing value for max-age attribute");
    }
    int age;
    try {
        age = Integer.parseInt(value);
    } catch (NumberFormatException e) {
        throw new MalformedCookieException ("Invalid max-age attribute: " 
                + value);
    }
    if (age < 0) {
        throw new MalformedCookieException ("Negative max-age attribute: " 
                + value);
    }
    cookie.setExpiryDate(new Date(System.currentTimeMillis() + age * 1000L));
}
项目:cJUnit-mc626    文件:RFC2965DomainAttributeHandler.java   
/**
 * Parse cookie domain attribute.
 */
public void parse(final SetCookie cookie, String domain)
        throws MalformedCookieException {
    if (cookie == null) {
        throw new IllegalArgumentException("Cookie may not be null");
    }
    if (domain == null) {
        throw new MalformedCookieException(
                "Missing value for domain attribute");
    }
    if (domain.trim().length() == 0) {
        throw new MalformedCookieException(
                "Blank value for domain attribute");
    }
    domain = domain.toLowerCase(Locale.ENGLISH);
    if (!domain.startsWith(".")) {
        // Per RFC 2965 section 3.2.2
        // "... If an explicitly specified value does not start with
        // a dot, the user agent supplies a leading dot ..."
        // That effectively implies that the domain attribute 
        // MAY NOT be an IP address of a host name
        domain = '.' + domain;
    }
    cookie.setDomain(domain);
}
项目:cJUnit-mc626    文件:RFC2109VersionHandler.java   
public void parse(final SetCookie cookie, final String value) 
        throws MalformedCookieException {
    if (cookie == null) {
        throw new IllegalArgumentException("Cookie may not be null");
    }
    if (value == null) {
        throw new MalformedCookieException("Missing value for version attribute");
    }
    if (value.trim().length() == 0) {
        throw new MalformedCookieException("Blank value for version attribute");
    }
    try {
       cookie.setVersion(Integer.parseInt(value));
    } catch (NumberFormatException e) {
        throw new MalformedCookieException("Invalid version: " 
            + e.getMessage());
    }
}
项目:ZTLib    文件:RFC2965VersionAttributeHandlerHC4.java   
/**
 * Parse cookie version attribute.
 */
public void parse(final SetCookie cookie, final String value)
        throws MalformedCookieException {
    Args.notNull(cookie, "Cookie");
    if (value == null) {
        throw new MalformedCookieException(
                "Missing value for version attribute");
    }
    int version = -1;
    try {
        version = Integer.parseInt(value);
    } catch (final NumberFormatException e) {
        version = -1;
    }
    if (version < 0) {
        throw new MalformedCookieException("Invalid cookie version.");
    }
    cookie.setVersion(version);
}
项目:ZTLib    文件:RFC2965DomainAttributeHandlerHC4.java   
/**
 * Parse cookie domain attribute.
 */
public void parse(
        final SetCookie cookie, final String domain) throws MalformedCookieException {
    Args.notNull(cookie, "Cookie");
    if (domain == null) {
        throw new MalformedCookieException(
                "Missing value for domain attribute");
    }
    if (domain.trim().length() == 0) {
        throw new MalformedCookieException(
                "Blank value for domain attribute");
    }
    String s = domain;
    s = s.toLowerCase(Locale.ENGLISH);
    if (!domain.startsWith(".")) {
        // Per RFC 2965 section 3.2.2
        // "... If an explicitly specified value does not start with
        // a dot, the user agent supplies a leading dot ..."
        // That effectively implies that the domain attribute
        // MAY NOT be an IP address of a host name
        s = '.' + s;
    }
    cookie.setDomain(s);
}
项目:ZTLib    文件:RFC2109VersionHandlerHC4.java   
public void parse(final SetCookie cookie, final String value)
        throws MalformedCookieException {
    Args.notNull(cookie, "Cookie");
    if (value == null) {
        throw new MalformedCookieException("Missing value for version attribute");
    }
    if (value.trim().length() == 0) {
        throw new MalformedCookieException("Blank value for version attribute");
    }
    try {
       cookie.setVersion(Integer.parseInt(value));
    } catch (final NumberFormatException e) {
        throw new MalformedCookieException("Invalid version: "
            + e.getMessage());
    }
}
项目:ZTLib    文件:BasicMaxAgeHandlerHC4.java   
public void parse(final SetCookie cookie, final String value)
        throws MalformedCookieException {
    Args.notNull(cookie, "Cookie");
    if (value == null) {
        throw new MalformedCookieException("Missing value for max-age attribute");
    }
    final int age;
    try {
        age = Integer.parseInt(value);
    } catch (final NumberFormatException e) {
        throw new MalformedCookieException ("Invalid max-age attribute: "
                + value);
    }
    if (age < 0) {
        throw new MalformedCookieException ("Negative max-age attribute: "
                + value);
    }
    cookie.setExpiryDate(new Date(System.currentTimeMillis() + age * 1000L));
}
项目:lams    文件:BasicPathHandler.java   
public void parse(final SetCookie cookie, String value)
        throws MalformedCookieException {
    if (cookie == null) {
        throw new IllegalArgumentException("Cookie may not be null");
    }
    if (value == null || value.trim().length() == 0) {
        value = "/";
    }
    cookie.setPath(value);
}
项目:lams    文件:RFC2965PortAttributeHandler.java   
/**
 * Parse cookie port attribute.
 */
public void parse(final SetCookie cookie, final String portValue)
        throws MalformedCookieException {
    if (cookie == null) {
        throw new IllegalArgumentException("Cookie may not be null");
    }
    if (cookie instanceof SetCookie2) {
        SetCookie2 cookie2 = (SetCookie2) cookie;
        if (portValue != null && portValue.trim().length() > 0) {
            int[] ports = parsePortAttribute(portValue);
            cookie2.setPorts(ports);
        }
    }
}
项目:lams    文件:RFC2109DomainHandler.java   
public void parse(final SetCookie cookie, final String value)
        throws MalformedCookieException {
    if (cookie == null) {
        throw new IllegalArgumentException("Cookie may not be null");
    }
    if (value == null) {
        throw new MalformedCookieException("Missing value for domain attribute");
    }
    if (value.trim().length() == 0) {
        throw new MalformedCookieException("Blank value for domain attribute");
    }
    cookie.setDomain(value);
}
项目:lams    文件:BasicCommentHandler.java   
public void parse(final SetCookie cookie, final String value)
        throws MalformedCookieException {
    if (cookie == null) {
        throw new IllegalArgumentException("Cookie may not be null");
    }
    cookie.setComment(value);
}
项目:lams    文件:BasicSecureHandler.java   
public void parse(final SetCookie cookie, final String value)
        throws MalformedCookieException {
    if (cookie == null) {
        throw new IllegalArgumentException("Cookie may not be null");
    }
    cookie.setSecure(true);
}
项目:lams    文件:BasicDomainHandler.java   
public void parse(final SetCookie cookie, final String value)
        throws MalformedCookieException {
    if (cookie == null) {
        throw new IllegalArgumentException("Cookie may not be null");
    }
    if (value == null) {
        throw new MalformedCookieException("Missing value for domain attribute");
    }
    if (value.trim().length() == 0) {
        throw new MalformedCookieException("Blank value for domain attribute");
    }
    cookie.setDomain(value);
}
项目:lams    文件:BasicExpiresHandler.java   
public void parse(final SetCookie cookie, final String value)
        throws MalformedCookieException {
    if (cookie == null) {
        throw new IllegalArgumentException("Cookie may not be null");
    }
    if (value == null) {
        throw new MalformedCookieException("Missing value for expires attribute");
    }
    try {
        cookie.setExpiryDate(DateUtils.parseDate(value, this.datepatterns));
    } catch (DateParseException dpe) {
        throw new MalformedCookieException("Unable to parse expires attribute: "
            + value);
    }
}
项目:lams    文件:RFC2965CommentUrlAttributeHandler.java   
public void parse(final SetCookie cookie, final String commenturl)
        throws MalformedCookieException {
    if (cookie instanceof SetCookie2) {
        SetCookie2 cookie2 = (SetCookie2) cookie;
        cookie2.setCommentURL(commenturl);
    }
}
项目:lams    文件:RFC2965DiscardAttributeHandler.java   
public void parse(final SetCookie cookie, final String commenturl)
        throws MalformedCookieException {
    if (cookie instanceof SetCookie2) {
        SetCookie2 cookie2 = (SetCookie2) cookie;
        cookie2.setDiscard(true);
    }
}
项目:remote-files-sync    文件:RFC2965PortAttributeHandlerHC4.java   
/**
 * Parse cookie port attribute.
 */
public void parse(final SetCookie cookie, final String portValue)
        throws MalformedCookieException {
    Args.notNull(cookie, "Cookie");
    if (cookie instanceof SetCookie2) {
        final SetCookie2 cookie2 = (SetCookie2) cookie;
        if (portValue != null && portValue.trim().length() > 0) {
            final int[] ports = parsePortAttribute(portValue);
            cookie2.setPorts(ports);
        }
    }
}
项目:remote-files-sync    文件:BasicDomainHandlerHC4.java   
public void parse(final SetCookie cookie, final String value)
        throws MalformedCookieException {
    Args.notNull(cookie, "Cookie");
    if (value == null) {
        throw new MalformedCookieException("Missing value for domain attribute");
    }
    if (value.trim().length() == 0) {
        throw new MalformedCookieException("Blank value for domain attribute");
    }
    cookie.setDomain(value);
}
项目:remote-files-sync    文件:BrowserCompatVersionAttributeHandler.java   
/**
 * Parse cookie version attribute.
 */
public void parse(final SetCookie cookie, final String value)
        throws MalformedCookieException {
    Args.notNull(cookie, "Cookie");
    if (value == null) {
        throw new MalformedCookieException("Missing value for version attribute");
    }
    int version = 0;
    try {
        version = Integer.parseInt(value);
    } catch (final NumberFormatException e) {
        // Just ignore invalid versions
    }
    cookie.setVersion(version);
}