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


Java Cookie.setPath方法代码示例

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


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

示例1: createSession

import io.netty.handler.codec.http.cookie.Cookie; //导入方法依赖的package包/类
private CommonResponse createSession(String username, Set<String> roles, boolean ldap)
        throws Exception {
    String sessionId = new BigInteger(130, secureRandom).toString(32);
    ImmutableSession session = ImmutableSession.builder()
            .caseAmbiguousUsername(username)
            .ldap(ldap)
            .roles(roles)
            .lastRequest(clock.currentTimeMillis())
            .build();
    sessionMap.put(sessionId, session);

    String layoutJson = layoutService
            .getLayoutJson(session.createAuthentication(central, configRepository));
    CommonResponse response = new CommonResponse(OK, MediaType.JSON_UTF_8, layoutJson);
    Cookie cookie =
            new DefaultCookie(configRepository.getWebConfig().sessionCookieName(), sessionId);
    cookie.setHttpOnly(true);
    cookie.setPath("/");
    response.setHeader(HttpHeaderNames.SET_COOKIE, ServerCookieEncoder.STRICT.encode(cookie));
    purgeExpiredSessions();

    auditSuccessfulLogin(username);
    return response;
}
 
开发者ID:glowroot,项目名称:glowroot,代码行数:25,代码来源:HttpSessionManager.java

示例2: addCookie

import io.netty.handler.codec.http.cookie.Cookie; //导入方法依赖的package包/类
/**
 * 添加一个Cookie
 * @param response response
 * @param name  cookie名字
 * @param value cookie值
 * @param domain cookie所在域
 * @param maxAge cookie生命周期  以秒为单位
 */
public static void addCookie(HttpResponse response,String name,String value,String domain,long maxAge){
    Cookie cookie = new DefaultCookie(name,value);
    cookie.setPath("/");
    if(domain!=null && domain.trim().length()>0) {
        cookie.setDomain(domain);
    }
    if(maxAge>0){
        cookie.setMaxAge(maxAge);
    }
    setCookie(response,cookie);
}
 
开发者ID:all4you,项目名称:redant,代码行数:20,代码来源:CookieHelper.java

示例3: deleteCookie

import io.netty.handler.codec.http.cookie.Cookie; //导入方法依赖的package包/类
/**
 * 删除一个Cookie
 * @param request
 * @param response
 * @param name
 * @return
 */
public static boolean deleteCookie(HttpRequest request,HttpResponse response,String name) {
    Cookie cookie = getCookie(request,name);
    if(cookie!=null){
        cookie.setMaxAge(0);
        cookie.setPath("/");
        setCookie(response,cookie);
        return true;
    }
    return false;
}
 
开发者ID:all4you,项目名称:redant,代码行数:18,代码来源:CookieHelper.java

示例4: createCookie

import io.netty.handler.codec.http.cookie.Cookie; //导入方法依赖的package包/类
public static Cookie createCookie(String name, String value, String domain,
		String path) {
	Cookie cookie = new DefaultCookie(name, value);
	cookie.setDomain(domain);
	cookie.setPath(path);
	return cookie;
}
 
开发者ID:rfxlab,项目名称:analytics-with-rfx,代码行数:8,代码来源:BaseHttpLogHandler.java

示例5: cookie

import io.netty.handler.codec.http.cookie.Cookie; //导入方法依赖的package包/类
@Override
public Response cookie(@NonNull String name, @NonNull String value, int maxAge) {
    Cookie nettyCookie = new io.netty.handler.codec.http.cookie.DefaultCookie(name, value);
    nettyCookie.setPath("/");
    nettyCookie.setMaxAge(maxAge);
    this.cookies.add(nettyCookie);
    return this;
}
 
开发者ID:lets-blade,项目名称:blade,代码行数:9,代码来源:HttpResponse.java

示例6: deleteSessionCookie

import io.netty.handler.codec.http.cookie.Cookie; //导入方法依赖的package包/类
void deleteSessionCookie(CommonResponse response) throws Exception {
    Cookie cookie = new DefaultCookie(configRepository.getWebConfig().sessionCookieName(), "");
    cookie.setHttpOnly(true);
    cookie.setMaxAge(0);
    cookie.setPath("/");
    response.setHeader(HttpHeaderNames.SET_COOKIE, ServerCookieEncoder.STRICT.encode(cookie));
}
 
开发者ID:glowroot,项目名称:glowroot,代码行数:8,代码来源:HttpSessionManager.java

示例7: writeDownloadHeaders

import io.netty.handler.codec.http.cookie.Cookie; //导入方法依赖的package包/类
public void writeDownloadHeaders(Channel ch, String name, String mime) {
      // Build the response object.
  	HttpResponse response = new DefaultHttpResponse(HttpVersion.HTTP_1_1, this.status);

      response.headers().set(Names.CONTENT_TYPE, StringUtil.isNotEmpty(mime) ? mime : MimeUtil.getMimeTypeForFile(name));
      
      if (StringUtil.isEmpty(name))
      	name = FileUtil.randomFilename("bin");
      
      response.headers().set("Content-Disposition", "attachment; filename=\"" + NetUtil.urlEncodeUTF8(name) + "\"");
      
Cookie dl = new DefaultCookie("fileDownload", "true");
dl.setPath("/");
      
      response.headers().add(Names.SET_COOKIE, ServerCookieEncoder.STRICT.encode(dl));

      // Encode the cookies
      for (Cookie c : this.cookies.values()) 
       response.headers().add(Names.SET_COOKIE, ServerCookieEncoder.STRICT.encode(c));
      
      for (Entry<CharSequence, String> h : this.headers.entrySet())
      	response.headers().set(h.getKey(), h.getValue());

  	response.headers().set(Names.TRANSFER_ENCODING, Values.CHUNKED);
      
      // Write the response.
      ch.writeAndFlush(response);
  }
 
开发者ID:Gadreel,项目名称:divconq,代码行数:29,代码来源:Response.java

示例8: startSession

import io.netty.handler.codec.http.cookie.Cookie; //导入方法依赖的package包/类
/**
 * Starts a session and sets the corresponding
 * session id as a cookie
 * 
 * @param value session value
 */
public void startSession(S value) {
	Cookie cookie = new DefaultCookie(sessions.getCookieKey(), sessions.startSession(value));
	cookie.setPath("/");
	setCookie(cookie);
}
 
开发者ID:lukasdietrich,项目名称:lambdatra,代码行数:12,代码来源:WrappedResponse.java


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