本文整理汇总了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;
}
示例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);
}
}
示例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);
}
示例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);
}
示例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);
}
示例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);
}
示例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;
}
}
示例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;
}
}
示例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;
}
}