org.simpleframework.http.Response.setCookie()方法的使用及代码示例

x33g5p2x  于2022-01-29 转载在 其他  
字(7.5k)|赞(0)|评价(0)|浏览(117)

本文整理了Java中org.simpleframework.http.Response.setCookie方法的一些代码示例,展示了Response.setCookie的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Response.setCookie方法的具体详情如下:
包路径:org.simpleframework.http.Response
类名称:Response
方法名:setCookie

Response.setCookie介绍

暂无

代码示例

代码示例来源:origin: org.simpleframework/simple-http

/**
* The <code>setCookie</code> method is used to set a cookie value 
* with the cookie name. This will add a cookie to the response
* stored under the name of the cookie, when this is committed it 
* will be added as a Set-Cookie header to the resulting response.
*
* @param cookie this is the cookie to be added to the response
* 
* @return returns the cookie that has been set in the response
*/
public Cookie setCookie(Cookie cookie) {
 return response.setCookie(cookie);
}

代码示例来源:origin: org.simpleframework/simple

/**
* The <code>setCookie</code> method is used to set a cookie value 
* with the cookie name. This will add a cookie to the response
* stored under the name of the cookie, when this is committed it 
* will be added as a Set-Cookie header to the resulting response.
*
* @param cookie this is the cookie to be added to the response
* 
* @return returns the cookie that has been set in the response
*/
public Cookie setCookie(Cookie cookie) {
 return response.setCookie(cookie);
}

代码示例来源:origin: ngallagher/simpleframework

/**
* The <code>setCookie</code> method is used to set a cookie value 
* with the cookie name. This will add a cookie to the response
* stored under the name of the cookie, when this is committed it 
* will be added as a Set-Cookie header to the resulting response.
*
* @param cookie this is the cookie to be added to the response
* 
* @return returns the cookie that has been set in the response
*/
public Cookie setCookie(Cookie cookie) {
 return response.setCookie(cookie);
}

代码示例来源:origin: org.simpleframework/simple

/**
* The <code>setCookie</code> method is used to set a cookie value 
* with the cookie name. This will add a cookie to the response
* stored under the name of the cookie, when this is committed it 
* will be added as a Set-Cookie header to the resulting response.
* This is a convenience method that avoids cookie creation.     
*
* @param name this is the cookie to be added to the response
* @param value this is the cookie value that is to be used
* 
* @return returns the cookie that has been set in the response
*/
public Cookie setCookie(String name, String value) {
 return response.setCookie(name, value);
}

代码示例来源:origin: ngallagher/simpleframework

/**
* The <code>setCookie</code> method is used to set a cookie value 
* with the cookie name. This will add a cookie to the response
* stored under the name of the cookie, when this is committed it 
* will be added as a Set-Cookie header to the resulting response.
* This is a convenience method that avoids cookie creation.     
*
* @param name this is the cookie to be added to the response
* @param value this is the cookie value that is to be used
* 
* @return returns the cookie that has been set in the response
*/
public Cookie setCookie(String name, String value) {
 return response.setCookie(name, value);
}

代码示例来源:origin: org.simpleframework/simple-http

/**
* The <code>setCookie</code> method is used to set a cookie value 
* with the cookie name. This will add a cookie to the response
* stored under the name of the cookie, when this is committed it 
* will be added as a Set-Cookie header to the resulting response.
* This is a convenience method that avoids cookie creation.     
*
* @param name this is the cookie to be added to the response
* @param value this is the cookie value that is to be used
* 
* @return returns the cookie that has been set in the response
*/
public Cookie setCookie(String name, String value) {
 return response.setCookie(name, value);
}

代码示例来源:origin: miltonio/milton2

@Override
public Cookie setCookie( String name, String value ) {
  org.simpleframework.http.Cookie c = baseResponse.setCookie( name, value );
  return new SimpletonCookie( c );
}

代码示例来源:origin: lantunes/fixd

public void setCookie(String name, String value) {
  Cookie cookie = new Cookie(name, value);
  response.setCookie(cookie);
}

代码示例来源:origin: restx/restx

@Override
public RestxResponse addCookie(String cookie, String value, RestxSessionCookieDescriptor cookieDescriptor, Duration expiration) {
  Cookie c = new Cookie(cookie, value, "/");
  c.setExpiry(expiration.getStandardSeconds() > 0 ? (int) expiration.getStandardSeconds() : -1);
  if(cookieDescriptor.getDomain().isPresent()) {
    c.setDomain(cookieDescriptor.getDomain().get());
  }
  if(cookieDescriptor.getSecure().isPresent()) {
    c.setSecure(cookieDescriptor.getSecure().get().booleanValue());
  }
  response.setCookie(c);
  return this;
}

代码示例来源:origin: restx/restx

@Override
public RestxResponse clearCookie(String cookie, RestxSessionCookieDescriptor cookieDescriptor) {
  Cookie c = new Cookie(cookie, "");
  c.setPath("/");
  c.setExpiry(0);
  if(cookieDescriptor.getDomain().isPresent()) {
    c.setDomain(cookieDescriptor.getDomain().get());
  }
  if(cookieDescriptor.getSecure().isPresent()) {
    c.setSecure(cookieDescriptor.getSecure().get().booleanValue());
  }
  response.setCookie(c);
  return this;
}

代码示例来源:origin: io.restx/restx-server-simple

@Override
public RestxResponse clearCookie(String cookie, RestxSessionCookieDescriptor cookieDescriptor) {
  Cookie c = new Cookie(cookie, "");
  c.setPath("/");
  c.setExpiry(0);
  if(cookieDescriptor.getDomain().isPresent()) {
    c.setDomain(cookieDescriptor.getDomain().get());
  }
  if(cookieDescriptor.getSecure().isPresent()) {
    c.setSecure(cookieDescriptor.getSecure().get().booleanValue());
  }
  response.setCookie(c);
  return this;
}

代码示例来源:origin: io.restx/restx-server-simple

@Override
public RestxResponse addCookie(String cookie, String value, RestxSessionCookieDescriptor cookieDescriptor, Duration expiration) {
  Cookie c = new Cookie(cookie, value, "/");
  c.setExpiry(expiration.getStandardSeconds() > 0 ? (int) expiration.getStandardSeconds() : -1);
  if(cookieDescriptor.getDomain().isPresent()) {
    c.setDomain(cookieDescriptor.getDomain().get());
  }
  if(cookieDescriptor.getSecure().isPresent()) {
    c.setSecure(cookieDescriptor.getSecure().get().booleanValue());
  }
  response.setCookie(c);
  return this;
}

代码示例来源:origin: lantunes/fixd

public void createNewSession(Request request, Response response, 
      Route route, SessionHandler sessionHandler, 
      UnmarshallerProvider unmarshallerProvider) {
    
    Session session = new Session();
    sessionHandler.onCreate(new SimpleHttpRequest(request, session, 
        route, unmarshallerProvider));
    sessions.put(session.getSessionId(), session);
    
    Cookie cookie = new Cookie(SESSION_COOKIE_NAME, session.getSessionId());
    response.setCookie(cookie);
  }
}

代码示例来源:origin: miltonio/milton2

@Override
public Cookie setCookie( Cookie cookie ) {
  if( cookie instanceof SimpletonCookie) {
    SimpletonCookie sc = (SimpletonCookie) cookie;
    baseResponse.setCookie( sc.getWrapped());
    return cookie;
  } else {
    org.simpleframework.http.Cookie c = new org.simpleframework.http.Cookie( cookie.getName(), cookie.getValue());
    c.setDomain( cookie.getDomain());
    c.setExpiry( cookie.getExpiry());
    c.setPath( cookie.getPath());
    c.setSecure( cookie.getSecure());
    c.setVersion( cookie.getVersion());
    baseResponse.setCookie( c );
    return new SimpletonCookie( c );
  }
}

代码示例来源:origin: CodeStory/fluent-http

@Override
public void setCookie(Cookie newCookie) {
 CookieDate cookieDate = new CookieDate();
 org.simpleframework.http.Cookie cookie = new org.simpleframework.http.Cookie(newCookie.name(), newCookie.value(), newCookie.path(), newCookie.isNew()) {
  @Override
  public String toString() {
   return getName() + "=" + getValue() + "; version=" +
    getVersion() + (getPath() == null ? "" : "; path=" + getPath()) +
    (getDomain() == null ? "" : "; domain=" + getDomain()) +
    (getExpiry() < 0 ? "" : "; expires=" + cookieDate.format(getExpiry())) +
    (getExpiry() < 0 ? "" : "; max-age=" + getExpiry()) +
    (isSecure() ? "; secure" : "") +
    (isProtected() ? "; httponly" : "");
  }
 };
 cookie.setExpiry(newCookie.expiry());
 cookie.setVersion(newCookie.version());
 cookie.setSecure(newCookie.isSecure());
 cookie.setProtected(newCookie.isHttpOnly());
 cookie.setDomain(newCookie.domain());
 response.setCookie(cookie);
}

相关文章