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


Java HttpCookie.isHttpOnly方法代码示例

本文整理汇总了Java中java.net.HttpCookie.isHttpOnly方法的典型用法代码示例。如果您正苦于以下问题:Java HttpCookie.isHttpOnly方法的具体用法?Java HttpCookie.isHttpOnly怎么用?Java HttpCookie.isHttpOnly使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在java.net.HttpCookie的用法示例。


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

示例1: of

import java.net.HttpCookie; //导入方法依赖的package包/类
/**
 * Create a new SerializableHttpCookie from a HttpCookie
 *
 * @param cookie An original cookie
 * @return SerializableHttpCookie that have same contents
 */
@NotNull
public static SerializableHttpCookie of(@NotNull HttpCookie cookie) {
    SerializableHttpCookie newCookie = new SerializableHttpCookie();
    newCookie.name = cookie.getName();
    newCookie.value = cookie.getValue();
    newCookie.comment = cookie.getComment();
    newCookie.commentURL = cookie.getCommentURL();
    newCookie.toDiscard = cookie.getDiscard();
    newCookie.domain = cookie.getDomain();
    newCookie.maxAge = cookie.getMaxAge();
    newCookie.path = cookie.getPath();
    newCookie.portlist = cookie.getPortlist();
    newCookie.secure = cookie.getSecure();
    newCookie.version = cookie.getVersion();

    // for Android (API level 24)
    // https://developer.android.com/reference/java/net/HttpCookie.html#isHttpOnly()
    try {
        newCookie.httpOnly = cookie.isHttpOnly();
    } catch (NoSuchMethodError e) {
        newCookie.httpOnly = false;
    }

    return newCookie;
}
 
开发者ID:emoji-gen,项目名称:bottler,代码行数:32,代码来源:SerializableHttpCookie.java

示例2: fromString

import java.net.HttpCookie; //导入方法依赖的package包/类
@Override
public NewCookie fromString(final String value) {
    if (value == null || value.isEmpty()) {
        return null;
    }

    final List<HttpCookie> httpCookies = HttpCookie.parse(value);
    final HttpCookie httpCookie = httpCookies.get(0);
    return new NewCookie(
            httpCookie.getName(),
            httpCookie.getValue(),
            httpCookie.getPath(),
            httpCookie.getDomain(),
            httpCookie.getVersion(),
            httpCookie.getComment(),
            (int) httpCookie.getMaxAge(),
            null,
            httpCookie.getSecure(),
            httpCookie.isHttpOnly());
}
 
开发者ID:minijax,项目名称:minijax,代码行数:21,代码来源:MinijaxNewCookieDelegate.java

示例3: filterHeaderField

import java.net.HttpCookie; //导入方法依赖的package包/类
/**
 * Returns a filtered version of the given headers value.
 *
 * Note: The implementation currently only filters out HttpOnly cookies
 *       from Set-Cookie and Set-Cookie2 headers.
 */
private String filterHeaderField(String name, String value) {
    if (value == null)
        return null;

    if (SET_COOKIE.equalsIgnoreCase(name) ||
        SET_COOKIE2.equalsIgnoreCase(name)) {

        // Filtering only if there is a cookie handler. [Assumption: the
        // cookie handler will store/retrieve the HttpOnly cookies]
        if (cookieHandler == null || value.length() == 0)
            return value;

        sun.misc.JavaNetHttpCookieAccess access =
                sun.misc.SharedSecrets.getJavaNetHttpCookieAccess();
        StringBuilder retValue = new StringBuilder();
        List<HttpCookie> cookies = access.parse(value);
        boolean multipleCookies = false;
        for (HttpCookie cookie : cookies) {
            // skip HttpOnly cookies
            if (cookie.isHttpOnly())
                continue;
            if (multipleCookies)
                retValue.append(',');  // RFC 2965, comma separated
            retValue.append(access.header(cookie));
            multipleCookies = true;
        }

        return retValue.length() == 0 ? "" : retValue.toString();
    }

    return value;
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:39,代码来源:HttpURLConnection.java

示例4: httpOnly

import java.net.HttpCookie; //导入方法依赖的package包/类
TestHttpCookie httpOnly(int index, boolean b) {
    HttpCookie cookie = cookies.get(index);
    if (cookie == null || b != cookie.isHttpOnly()) {
        raiseError("HttpOnly", String.valueOf(cookie.isHttpOnly()), String.valueOf(b));
    }
    return this;
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:8,代码来源:TestHttpCookie.java

示例5: filterHeaderField

import java.net.HttpCookie; //导入方法依赖的package包/类
/**
 * Returns a filtered version of the given headers value.
 *
 * Note: The implementation currently only filters out HttpOnly cookies
 *       from Set-Cookie and Set-Cookie2 headers.
 */
private String filterHeaderField(String name, String value) {
    if (value == null)
        return null;

    if (SET_COOKIE.equalsIgnoreCase(name) ||
        SET_COOKIE2.equalsIgnoreCase(name)) {

        // Filtering only if there is a cookie handler. [Assumption: the
        // cookie handler will store/retrieve the HttpOnly cookies]
        if (cookieHandler == null || value.length() == 0)
            return value;

        JavaNetHttpCookieAccess access =
                SharedSecrets.getJavaNetHttpCookieAccess();
        StringJoiner retValue = new StringJoiner(",");  // RFC 2965, comma separated
        List<HttpCookie> cookies = access.parse(value);
        for (HttpCookie cookie : cookies) {
            // skip HttpOnly cookies
            if (!cookie.isHttpOnly())
                retValue.add(access.header(cookie));
        }
        return retValue.toString();
    }

    return value;
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:33,代码来源:HttpURLConnection.java


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