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


Java Cookie.setVersion方法代码示例

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


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

示例1: getCookies

import javax.servlet.http.Cookie; //导入方法依赖的package包/类
@Override
public Cookie[] getCookies() {
    String cookieString = this.originalRequest.headers().get(COOKIE);
    if (cookieString != null) {
        Set<io.netty.handler.codec.http.Cookie> cookies = CookieDecoder.decode(cookieString);
        if (!cookies.isEmpty()) {
            Cookie[] cookiesArray = new Cookie[cookies.size()];
            int indx = 0;
            for (io.netty.handler.codec.http.Cookie c : cookies) {
                Cookie cookie = new Cookie(c.name(), c.value());
                cookie.setComment(c.comment());
                cookie.setDomain(c.domain());
                cookie.setMaxAge((int) c.maxAge());
                cookie.setPath(c.path());
                cookie.setSecure(c.isSecure());
                cookie.setVersion(c.version());
                cookiesArray[indx] = cookie;
                indx++;
            }
            return cookiesArray;

        }
    }
    return null;
}
 
开发者ID:geeker-lait,项目名称:tasfe-framework,代码行数:26,代码来源:HttpServletRequestImpl.java

示例2: copyProxyCookie

import javax.servlet.http.Cookie; //导入方法依赖的package包/类
/**
 * Copy cookie from the proxy to the servlet client. Replaces cookie path to local path and renames cookie to avoid
 * collisions.
 */
protected void copyProxyCookie(HttpServletRequest servletRequest, HttpServletResponse servletResponse, Header header) {
    List<HttpCookie> cookies = HttpCookie.parse(header.getValue());
    String path = servletRequest.getContextPath(); // path starts with / or is empty string
    path += servletRequest.getServletPath(); // servlet path starts with / or is empty string

    for (HttpCookie cookie : cookies) {
        // set cookie name prefixed w/ a proxy value so it won't collide w/ other cookies
        String proxyCookieName = getCookieNamePrefix() + cookie.getName();
        Cookie servletCookie = new Cookie(proxyCookieName, cookie.getValue());
        servletCookie.setComment(cookie.getComment());
        servletCookie.setMaxAge((int) cookie.getMaxAge());
        servletCookie.setPath(path); // set to the path of the proxy servlet
        // don't set cookie domain
        servletCookie.setSecure(cookie.getSecure());
        servletCookie.setVersion(cookie.getVersion());
        servletResponse.addCookie(servletCookie);
    }
}
 
开发者ID:bluecreator,项目名称:http-agent,代码行数:23,代码来源:AgentServlet.java

示例3: addCookieToResponse

import javax.servlet.http.Cookie; //导入方法依赖的package包/类
private void addCookieToResponse(HttpServletResponse response, String name, String value, int secondsToLive, boolean httpOnly) {
    Cookie cookie = new Cookie(name, value == null ? null : URLEncoder.encode(value));
    cookie.setMaxAge(secondsToLive);

    if (domain != null) {
        cookie.setDomain(domain);
    }

    if (path != null) {
        cookie.setPath(path);
    }

    if (version != null) {
        cookie.setVersion(version);
    }
    if (httpOnly) {
        cookie.setHttpOnly(true);
    }
    response.addCookie(cookie);
}
 
开发者ID:haibodong,项目名称:JSiter,代码行数:21,代码来源:CookieUtil.java

示例4: setSaveCookie

import javax.servlet.http.Cookie; //导入方法依赖的package包/类
public static void setSaveCookie(HttpServletRequest request, HttpServletResponse response, String name, String value, int maxAge) {
    if (value == null){
        value = StringUtils.EMPTY;
    }
    String path = request.getContextPath() != null ? request.getContextPath() : "/";
    if ("".equals(path)){
        path = "/";
    }
    Cookie cookie = new Cookie(name, value);
    cookie.setMaxAge(maxAge);
    cookie.setPath(path);
    cookie.setVersion(1);
    addSecureParam(request, cookie);
    response.addCookie(cookie);
}
 
开发者ID:bridgeli,项目名称:netty-socketio-demo,代码行数:16,代码来源:CookieUtils.java

示例5: setCookie

import javax.servlet.http.Cookie; //导入方法依赖的package包/类
public static void setCookie(HttpServletRequest request, HttpServletResponse response,
        String name, String value, int maxAge) {
    if (value == null) {
        value = "";
    }
    String path = request.getContextPath() != null ? request.getContextPath() : "/";
    if ("".equals(path)) {
        path = "/";
    }
    Cookie cookie = new Cookie(name, value);
    cookie.setPath(path);
    cookie.setVersion(1);
    addSecureParam(request, cookie);
    response.addCookie(cookie);
}
 
开发者ID:bridgeli,项目名称:netty-socketio-demo,代码行数:16,代码来源:CookieUtils.java

示例6: setSessionCookie

import javax.servlet.http.Cookie; //导入方法依赖的package包/类
public static void setSessionCookie(HttpServletRequest request, HttpServletResponse response, String name, String value) {
    if (value == null){
        value = StringUtils.EMPTY;
    }
    String path = request.getContextPath() != null ? request.getContextPath() : "/";
    if ("".equals(path)){
        path = "/";
    }
    Cookie cookie = new Cookie(name, value);
    cookie.setPath(path);
    cookie.setVersion(1);
    addSecureParam(request, cookie);
    response.addCookie(cookie);
}
 
开发者ID:bridgeli,项目名称:netty-socketio-demo,代码行数:15,代码来源:CookieUtils.java

示例7: parseCookies

import javax.servlet.http.Cookie; //导入方法依赖的package包/类
/**
 * Parse cookies.
 */
protected void parseCookies() {

    cookiesParsed = true;

    Cookies serverCookies = coyoteRequest.getCookies();
    int count = serverCookies.getCookieCount();
    if (count <= 0) {
        return;
    }

    cookies = new Cookie[count];

    int idx=0;
    for (int i = 0; i < count; i++) {
        ServerCookie scookie = serverCookies.getCookie(i);
        try {
            /*
            we must unescape the '\\' escape character
            */
            Cookie cookie = new Cookie(scookie.getName().toString(),null);
            int version = scookie.getVersion();
            cookie.setVersion(version);
            cookie.setValue(unescape(scookie.getValue().toString()));
            cookie.setPath(unescape(scookie.getPath().toString()));
            String domain = scookie.getDomain().toString();
            if (domain!=null)
             {
                cookie.setDomain(unescape(domain));//avoid NPE
            }
            String comment = scookie.getComment().toString();
            cookie.setComment(version==1?unescape(comment):null);
            cookies[idx++] = cookie;
        } catch(IllegalArgumentException e) {
            // Ignore bad cookie
        }
    }
    if( idx < count ) {
        Cookie [] ncookies = new Cookie[idx];
        System.arraycopy(cookies, 0, ncookies, 0, idx);
        cookies = ncookies;
    }

}
 
开发者ID:sunmingshuai,项目名称:apache-tomcat-7.0.73-with-comment,代码行数:47,代码来源:Request.java

示例8: parseCookies

import javax.servlet.http.Cookie; //导入方法依赖的package包/类
/**
 * Parse cookies.
 */
protected void parseCookies() {

    cookiesParsed = true;

    Cookies serverCookies = coyoteRequest.getCookies();
    int count = serverCookies.getCookieCount();
    if (count <= 0)
        return;

    cookies = new Cookie[count];

    int idx=0;
    for (int i = 0; i < count; i++) {
        ServerCookie scookie = serverCookies.getCookie(i);
        try {
            /*
            we must unescape the '\\' escape character
            */
            Cookie cookie = new Cookie(scookie.getName().toString(),null);
            int version = scookie.getVersion();
            cookie.setVersion(version);
            cookie.setValue(unescape(scookie.getValue().toString()));
            cookie.setPath(unescape(scookie.getPath().toString()));
            String domain = scookie.getDomain().toString();
            if (domain!=null) 
                cookie.setDomain(unescape(domain));//avoid NPE
            String comment = scookie.getComment().toString();
            cookie.setComment(version==1?unescape(comment):null);
            cookies[idx++] = cookie;
        } catch(IllegalArgumentException e) {
            // Ignore bad cookie
        }
    }
    if( idx < count ) {
        Cookie [] ncookies = new Cookie[idx];
        System.arraycopy(cookies, 0, ncookies, 0, idx);
        cookies = ncookies;
    }

}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:44,代码来源:Request.java

示例9: parseCookies

import javax.servlet.http.Cookie; //导入方法依赖的package包/类
/**
 * Parse cookies.
 */
protected void parseCookies() {

	cookiesParsed = true;

	Cookies serverCookies = coyoteRequest.getCookies();
	int count = serverCookies.getCookieCount();
	if (count <= 0) {
		return;
	}

	cookies = new Cookie[count];

	int idx = 0;
	for (int i = 0; i < count; i++) {
		ServerCookie scookie = serverCookies.getCookie(i);
		try {
			/*
			 * we must unescape the '\\' escape character
			 */
			Cookie cookie = new Cookie(scookie.getName().toString(), null);
			int version = scookie.getVersion();
			cookie.setVersion(version);
			cookie.setValue(unescape(scookie.getValue().toString()));
			cookie.setPath(unescape(scookie.getPath().toString()));
			String domain = scookie.getDomain().toString();
			if (domain != null) {
				cookie.setDomain(unescape(domain));// avoid NPE
			}
			String comment = scookie.getComment().toString();
			cookie.setComment(version == 1 ? unescape(comment) : null);
			cookies[idx++] = cookie;
		} catch (IllegalArgumentException e) {
			// Ignore bad cookie
		}
	}
	if (idx < count) {
		Cookie[] ncookies = new Cookie[idx];
		System.arraycopy(cookies, 0, ncookies, 0, idx);
		cookies = ncookies;
	}

}
 
开发者ID:how2j,项目名称:lazycat,代码行数:46,代码来源:Request.java


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