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

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

Introduction

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

Prototype

@Deprecated
String getName();

Source Link

Usage

From source file:com.barchart.http.server.PooledServerRequest.java

License:BSD License

@Override
public Map<String, Cookie> getCookies() {

    if (cookies == null) {

        cookies = new HashMap<String, Cookie>();

        final Set<Cookie> cookieSet = CookieDecoder.decode(nettyRequest.headers().get("Cookie"));

        for (final Cookie cookie : cookieSet) {
            cookies.put(cookie.getName(), cookie);
        }/*from   w ww .  j a  v a  2s  .co  m*/

    }

    return cookies;

}

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()));
    }/*from   w  ww  . jav 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.cu.http.container.core.utils.Utils.java

License:Apache License

public static Collection<Cookie> getCookies(String name, HttpRequest request) {
    String cookieString = request.headers().get(COOKIE);
    if (cookieString != null) {
        List<Cookie> foundCookie = new ArrayList<Cookie>();
        Set<Cookie> cookies = CookieDecoder.decode(cookieString);
        for (Cookie cookie : cookies) {
            if (cookie.getName().equals(name)) {
                foundCookie.add(cookie);
            }//  www . j  a  v a  2s  .  c o  m
        }

        return foundCookie;
    }
    return null;
}

From source file:com.cu.http.container.core.utils.Utils.java

License:Apache License

public static Collection<Cookie> getCookies(String name, HttpResponse response) {
    String cookieString = response.headers().get(COOKIE);
    if (cookieString != null) {
        List<Cookie> foundCookie = new ArrayList<Cookie>();
        Set<Cookie> cookies = CookieDecoder.decode(cookieString);
        for (Cookie cookie : cookies) {
            if (cookie.getName().equals(name)) {
                foundCookie.add(cookie);
            }/*  w  ww  .ja  va2  s .  c o  m*/
        }

        return foundCookie;
    }
    return null;
}

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  w  w. j a  v  a 2s .  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 w  w  w .  j a 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 {/*w  w  w . jav  a2s . 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   www.java 2s.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;
}