当前位置: 首页>>代码示例>>Java>>正文


Java SetCookie类代码示例

本文整理汇总了Java中org.apache.http.cookie.SetCookie的典型用法代码示例。如果您正苦于以下问题:Java SetCookie类的具体用法?Java SetCookie怎么用?Java SetCookie使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


SetCookie类属于org.apache.http.cookie包,在下文中一共展示了SetCookie类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: parse

import org.apache.http.cookie.SetCookie; //导入依赖的package包/类
/**
 * 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);
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:24,代码来源:RFC2965VersionAttributeHandler.java

示例2: parse

import org.apache.http.cookie.SetCookie; //导入依赖的package包/类
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));
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:22,代码来源:BasicMaxAgeHandler.java

示例3: parse

import org.apache.http.cookie.SetCookie; //导入依赖的package包/类
/**
 * 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);
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:28,代码来源:RFC2965DomainAttributeHandler.java

示例4: parse

import org.apache.http.cookie.SetCookie; //导入依赖的package包/类
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());
    }
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:19,代码来源:RFC2109VersionHandler.java

示例5: parse

import org.apache.http.cookie.SetCookie; //导入依赖的package包/类
/**
 * 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);
}
 
开发者ID:xxonehjh,项目名称:remote-files-sync,代码行数:22,代码来源:RFC2965VersionAttributeHandlerHC4.java

示例6: parse

import org.apache.http.cookie.SetCookie; //导入依赖的package包/类
/**
 * 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);
}
 
开发者ID:xxonehjh,项目名称:remote-files-sync,代码行数:27,代码来源:RFC2965DomainAttributeHandlerHC4.java

示例7: parse

import org.apache.http.cookie.SetCookie; //导入依赖的package包/类
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());
    }
}
 
开发者ID:xxonehjh,项目名称:remote-files-sync,代码行数:17,代码来源:RFC2109VersionHandlerHC4.java

示例8: parse

import org.apache.http.cookie.SetCookie; //导入依赖的package包/类
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));
}
 
开发者ID:xxonehjh,项目名称:remote-files-sync,代码行数:20,代码来源:BasicMaxAgeHandlerHC4.java

示例9: parse

import org.apache.http.cookie.SetCookie; //导入依赖的package包/类
/**
 * 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);
}
 
开发者ID:MyPureCloud,项目名称:purecloud-iot,代码行数:19,代码来源:BrowserCompatVersionAttributeHandler.java

示例10: parse

import org.apache.http.cookie.SetCookie; //导入依赖的package包/类
/**
 * 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);
}
 
开发者ID:MyPureCloud,项目名称:purecloud-iot,代码行数:23,代码来源:RFC2965VersionAttributeHandler.java

示例11: parse

import org.apache.http.cookie.SetCookie; //导入依赖的package包/类
@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));
}
 
开发者ID:MyPureCloud,项目名称:purecloud-iot,代码行数:21,代码来源:BasicMaxAgeHandler.java

示例12: parse

import org.apache.http.cookie.SetCookie; //导入依赖的package包/类
/**
 * 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);
}
 
开发者ID:MyPureCloud,项目名称:purecloud-iot,代码行数:28,代码来源:RFC2965DomainAttributeHandler.java

示例13: parse

import org.apache.http.cookie.SetCookie; //导入依赖的package包/类
@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());
    }
}
 
开发者ID:MyPureCloud,项目名称:purecloud-iot,代码行数:18,代码来源:RFC2109VersionHandler.java

示例14: parse

import org.apache.http.cookie.SetCookie; //导入依赖的package包/类
@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);
}
 
开发者ID:MyPureCloud,项目名称:purecloud-iot,代码行数:19,代码来源:BasicDomainHandler.java

示例15: parse

import org.apache.http.cookie.SetCookie; //导入依赖的package包/类
@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);
    }
}
 
开发者ID:MyPureCloud,项目名称:purecloud-iot,代码行数:20,代码来源:LaxMaxAgeHandler.java


注:本文中的org.apache.http.cookie.SetCookie类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。