本文整理汇总了Java中io.netty.handler.codec.http.Cookie.getValue方法的典型用法代码示例。如果您正苦于以下问题:Java Cookie.getValue方法的具体用法?Java Cookie.getValue怎么用?Java Cookie.getValue使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类io.netty.handler.codec.http.Cookie
的用法示例。
在下文中一共展示了Cookie.getValue方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getClientSessionId
import io.netty.handler.codec.http.Cookie; //导入方法依赖的package包/类
public static String getClientSessionId(HttpRequest req) {
Set<Cookie> cookies;
String value = req.headers().get(HttpHeaders.Names.COOKIE);
if (value == null) {
return null;
} else {
cookies = CookieDecoder.decode(value);
}
for (Cookie cookie : cookies) {
if (cookie.getName().contains("JSESSIONID")) {
return cookie.getValue();
}
}
return null;
}
示例2: copyToServletCookie
import io.netty.handler.codec.http.Cookie; //导入方法依赖的package包/类
void copyToServletCookie(FullHttpRequest fullHttpReq, MockHttpServletRequest servletRequest){
String cookieString = fullHttpReq.headers().get(HttpHeaders.Names.COOKIE);
if (cookieString != null) {
Set<Cookie> cookies = CookieDecoder.decode(cookieString);
if (!cookies.isEmpty()) {
// Reset the cookies if necessary.
javax.servlet.http.Cookie[] sCookies = new javax.servlet.http.Cookie[cookies.size()];
int i = 0;
for (Cookie cookie: cookies) {
javax.servlet.http.Cookie sCookie = new javax.servlet.http.Cookie(cookie.getName(), cookie.getValue());
sCookie.setPath(cookie.getPath());
sCookie.setMaxAge((int) cookie.getMaxAge());
sCookies[i++] = sCookie;
}
servletRequest.setCookies(sCookies);
}
} else {
servletRequest.setCookies( new javax.servlet.http.Cookie[0]);
}
}
示例3: getCookie
import io.netty.handler.codec.http.Cookie; //导入方法依赖的package包/类
@Override
public String getCookie(final String cookieName) {
if (cookies == null) {
populateCookies();
}
final Cookie cookie = cookies.get(cookieName);
return cookie != null ? cookie.getValue() : null;
}
示例4: get
import io.netty.handler.codec.http.Cookie; //导入方法依赖的package包/类
public static String get(String name, HttpServerRequest request) {
if (request.headers().get("Cookie") != null) {
Set<Cookie> cookies = CookieDecoder.decode(request.headers().get("Cookie"));
for (Cookie c : cookies) {
if (c.getName().equals(name)) {
return c.getValue();
}
}
}
return null;
}
示例5: readAuthentication
import io.netty.handler.codec.http.Cookie; //导入方法依赖的package包/类
private String readAuthentication(HttpRequest request) {
String requestCookie = request.headers().get("Cookie");
if (requestCookie == null) {
return null;
}
Set<Cookie> cookies = CookieDecoder.decode(requestCookie);
for (Cookie cookie : cookies) {
if ("who-am-i".equals(cookie.getName())) {
return cookie.getValue();
}
}
return null;
}