Example usage for io.netty.handler.codec.http Cookie getValue

List of usage examples for io.netty.handler.codec.http Cookie getValue

Introduction

In this page you can find the example usage for io.netty.handler.codec.http Cookie getValue.

Prototype

@Deprecated
String getValue();

Source Link

Usage

From source file:com.chiorichan.session.SessionUtils.java

License:Mozilla Public License

public static Map<String, Candy> poleCandies(HttpRequestWrapper request) throws IllegalArgumentException {
    Map<String, Candy> candies = new LinkedHashMap<String, Candy>();
    String cookies = request.getHeaders().get("Cookie");
    if (cookies == null)
        return candies;

    Set<Cookie> var1 = CookieDecoder.decode(cookies);

    if (var1 == null || var1.isEmpty())
        return candies;

    for (Cookie cookie : var1) {
        candies.put(cookie.getName(), new Candy(cookie.getName(), cookie.getValue()));
    }/*  w  w w  .  ja  v  a  2  s . c  o m*/

    return candies;
}

From source file:com.cu.http.container.core.adaptor.NettyServletResponse.java

License:Apache License

public void addCookie(Cookie cookie) {
    HttpHeaders.addHeader(this.originalResponse, SET_COOKIE,
            ClientCookieEncoder.encode(cookie.getName(), cookie.getValue()));
}

From source file:com.github.ambry.rest.NettyRequestTest.java

License:Open Source License

/**
 * Convert a set of {@link Cookie} to a string that could be used as header value in http request
 * @param cookies that needs conversion/*from w  ww .  j ava2  s  .c  o  m*/
 * @return string representation of the set of cookies
 */
private String getCookiesHeaderValue(Set<Cookie> cookies) {
    StringBuilder cookieStr = new StringBuilder();
    for (Cookie cookie : cookies) {
        if (cookieStr.length() != 0) {
            cookieStr.append("; ");
        }
        cookieStr.append(cookie.getName()).append("=").append(cookie.getValue());
    }
    return cookieStr.toString();
}

From source file:com.github.ambry.rest.NettyRequestTest.java

License:Open Source License

/**
 * Compares a set of HttpCookies {@link Cookie} with a set of Java Cookies {@link javax.servlet.http.Cookie} for
 * equality in values/*from ww  w. ja  va 2 s  .c o  m*/
 * @param expected Set of {@link Cookie}s to be compared with the {@code actual}
 * @param actual Set of {@link javax.servlet.http.Cookie}s to be compared with those of {@code expected}
 */
private void compareCookies(Set<Cookie> expected, Set<javax.servlet.http.Cookie> actual) {
    Assert.assertEquals("Size didn't match", expected.size(), actual.size());
    HashMap<String, Cookie> expectedHashMap = new HashMap<String, Cookie>();
    for (Cookie cookie : expected) {
        expectedHashMap.put(cookie.getName(), cookie);
    }
    for (javax.servlet.http.Cookie cookie : actual) {
        Assert.assertEquals("Value field didn't match ", expectedHashMap.get(cookie.getName()).getValue(),
                cookie.getValue());
    }
}

From source file:com.mastfrog.acteur.wicket.adapters.CookieAdapter.java

License:Open Source License

public CookieAdapter(io.netty.handler.codec.http.Cookie cookie) {
    super(cookie.getName(), cookie.getValue());
    this.cookie = cookie;
}

From source file:com.mastfrog.acteur.wicket.adapters.CookieConverter.java

License:Open Source License

@Override
public Cookie unconvert(javax.servlet.http.Cookie t) {
    if (t instanceof CookieAdapter) {
        return ((CookieAdapter) t).cookie;
    } else {/*  ww  w  . j  a v a  2s  .  c o m*/
        DefaultCookie dc = new DefaultCookie(t.getName(), t.getValue());
        dc.setComment(t.getComment());
        dc.setMaxAge(t.getMaxAge());
        dc.setDomain(t.getDomain());
        dc.setVersion(t.getVersion());
        return dc;
    }
}

From source file:com.mastfrog.acteur.wicket.EnsureSessionId.java

License:Open Source License

/**
 * Locate the session id in the request cookies
 * @param evt The HTTP request/*from   ww w.  j  av  a  2 s  .c o m*/
 * @return A session id if the cookie is present, or null if it is not
 */
static SessionId findSessionId(HttpEvent evt) {
    Cookie[] cookies = evt.getHeader(Headers.COOKIE);
    SessionId result = null;
    if (cookies != null && cookies.length > 0) {
        for (Cookie ck : cookies) {
            if (ActeurSessionStore.COOKIE_NAME.equals(ck.getName())) {
                result = new SessionId(ck.getValue());
            }
        }
    }
    return result;
}

From source file:com.mastfrog.netty.http.client.CookieStore.java

License:Open Source License

public String get(String name) {
    Lock readLock = lock.readLock();
    readLock.lock();//  ww  w  .  ja  v  a 2 s. c  o m
    try {
        for (Cookie ck : cookies) {
            if (name.equals(ck.getName())) {
                return ck.getValue();
            }
        }
    } finally {
        readLock.unlock();
    }
    return null;
}

From source file:com.sample.HelloWorldWithUnity3d.PingVerticle.java

License:Apache License

String GetSessionId(HttpServerRequest req) {
    String value = req.headers().get("Cookie");
    if (value != null) {
        Set<Cookie> cookies = CookieDecoder.decode(value);
        for (final Cookie cookie : cookies) {
            if ("sessionId".equals(cookie.getName())) {
                return cookie.getValue();
            }/*from  w ww .  jav  a  2 s . c om*/
        }
    }

    return null;
}

From source file:com.titilink.camel.rest.common.AdapterRestletUtil.java

License:LGPL

/**
 * ?Cookie//  w ww .j  a  v  a 2s.c  o m
 *
 * @param cookie
 * @return
 */
public static org.restlet.data.Cookie parseToRestletCookie(Cookie cookie) {
    if (null == cookie) {
        LOGGER.error("cookie=null");
        return null;
    }
    org.restlet.data.Cookie restletCookie = new org.restlet.data.Cookie();
    restletCookie.setDomain(cookie.getDomain());
    restletCookie.setVersion(cookie.getVersion());
    restletCookie.setName(cookie.getName());
    restletCookie.setValue(cookie.getValue());
    restletCookie.setPath(cookie.getPath());
    return restletCookie;
}