本文整理汇总了Java中io.netty.handler.codec.http.cookie.Cookie.value方法的典型用法代码示例。如果您正苦于以下问题:Java Cookie.value方法的具体用法?Java Cookie.value怎么用?Java Cookie.value使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类io.netty.handler.codec.http.cookie.Cookie
的用法示例。
在下文中一共展示了Cookie.value方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getUser
import io.netty.handler.codec.http.cookie.Cookie; //导入方法依赖的package包/类
/**
* 从Http Cookie中获取用户Id
*
* @param data
* @return
*/
public static final PushUser getUser(HandshakeData data) {
String _cookie = data.getSingleHeader(HttpHeaders.Names.COOKIE);
if (_cookie != null) {
Set<Cookie> cookies = ServerCookieDecoder.LAX.decode(_cookie);
for (Cookie cookie : cookies) {
if (TokenManager.LOGIN_COOKIE_NAME.equals(cookie.name())) {
String value = cookie.value();
if (value != null) {
return getUserIdFromCookie(value);
}
}
}
}
return null;
}
示例2: onRequestReceived
import io.netty.handler.codec.http.cookie.Cookie; //导入方法依赖的package包/类
@Override
public void onRequestReceived(ChannelHandlerContext ctx, HttpRequest request) {
HttpSessionThreadLocal.unset();
Collection<Cookie> cookies = Utils.getCookies(HttpSessionImpl.SESSION_ID_KEY, request);
if (cookies != null) {
for (Cookie cookie : cookies) {
String jsessionId = cookie.value();
HttpSession s = HttpSessionThreadLocal.getSessionStore().findSession(jsessionId);
if (s != null) {
HttpSessionThreadLocal.set(s);
this.sessionRequestedByCookie = true;
break;
}
}
}
}
示例3: extract
import io.netty.handler.codec.http.cookie.Cookie; //导入方法依赖的package包/类
@Override
public String extract(ObjectNode node, RakamHttpRequest request)
{
for (Cookie cookie : request.cookies()) {
if (name.equals(cookie.name())) {
// TODO fixme: the value of cookie parameter always must be String.
return cookie.value();
}
}
if (required) {
throw new HttpRequestException("'" + name + "' cookie is required.", BAD_REQUEST);
}
return null;
}
示例4: getUserFromCookie
import io.netty.handler.codec.http.cookie.Cookie; //导入方法依赖的package包/类
public User getUserFromCookie(FullHttpRequest request) {
String cookieString = request.headers().get(HttpHeaderNames.COOKIE);
if (cookieString != null) {
Set<Cookie> cookies = ServerCookieDecoder.STRICT.decode(cookieString);
if (!cookies.isEmpty()) {
for (Cookie cookie : cookies) {
if (isValid(cookie)) {
String token = cookie.value();
return httpSession.get(token);
}
}
}
}
return null;
}
示例5: getSessionId
import io.netty.handler.codec.http.cookie.Cookie; //导入方法依赖的package包/类
@Nullable
String getSessionId(CommonRequest request) throws Exception {
String cookieHeader = request.getHeader(HttpHeaderNames.COOKIE);
if (cookieHeader == null) {
return null;
}
Set<Cookie> cookies = ServerCookieDecoder.STRICT.decode(cookieHeader);
for (Cookie cookie : cookies) {
if (cookie.name().equals(configRepository.getWebConfig().sessionCookieName())) {
return cookie.value();
}
}
return null;
}
示例6: getCookieValue
import io.netty.handler.codec.http.cookie.Cookie; //导入方法依赖的package包/类
@Override
public String getCookieValue(String cookieName) {
Cookie cookie = cookies.get(cookieName);
return (cookie == null) ? null : cookie.value();
}
示例7: getCookieValue
import io.netty.handler.codec.http.cookie.Cookie; //导入方法依赖的package包/类
/**
* 获取Cookie的值
* @param request HttpRequest
* @param name cookie名字
* @return
*/
public static String getCookieValue(HttpRequest request,String name){
Cookie cookie = getCookie(request,name);
return cookie.value();
}