Example usage for io.netty.handler.codec.http.cookie Cookie domain

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

Introduction

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

Prototype

String domain();

Source Link

Document

Returns the domain of this Cookie .

Usage

From source file:io.vertx.ext.web.client.impl.CookieStoreImpl.java

License:Open Source License

@Override
public CookieStore put(Cookie cookie) {
    Key key = new Key(cookie.domain(), cookie.path(), cookie.name());
    if (key.domain.equals(Key.NO_DOMAIN)) {
        noDomainCookies.put(key, cookie);
        return this;
    }//  ww  w  .  j av a  2s  .  c  om
    domainCookies.put(key, cookie);
    return this;
}

From source file:io.vertx.ext.web.client.impl.CookieStoreImpl.java

License:Open Source License

@Override
public CookieStore remove(Cookie cookie) {
    Key key = new Key(cookie.domain(), cookie.path(), cookie.name());
    if (key.domain.equals(Key.NO_DOMAIN)) {
        noDomainCookies.remove(key);/*from  w w  w  .  j  a  v a  2s  . co m*/
    } else {
        domainCookies.remove(key);
    }
    return this;
}

From source file:org.asynchttpclient.cookie.ThreadSafeCookieStore.java

License:Open Source License

private void add(String requestDomain, String requestPath, Cookie cookie) {

    AbstractMap.SimpleEntry<String, Boolean> pair = cookieDomain(cookie.domain(), requestDomain);
    String keyDomain = pair.getKey();
    boolean hostOnly = pair.getValue();
    String keyPath = cookiePath(cookie.path(), requestPath);
    CookieKey key = new CookieKey(cookie.name().toLowerCase(), keyDomain, keyPath);

    if (hasCookieExpired(cookie, 0))
        cookieJar.remove(key);//from w w w  .  ja  va  2  s  . com
    else
        cookieJar.put(key, new StoredCookie(cookie, hostOnly, cookie.maxAge() != Cookie.UNDEFINED_MAX_AGE));
}

From source file:org.atmosphere.nettosphere.BridgeRuntime.java

License:Apache License

private Set<javax.servlet.http.Cookie> getCookies(final HttpRequest request) {
    Set<javax.servlet.http.Cookie> result = new HashSet<javax.servlet.http.Cookie>();
    String cookieHeader = request.headers().get("Cookie");
    if (cookieHeader != null) {
        Set<io.netty.handler.codec.http.cookie.Cookie> cookies = ServerCookieDecoder.LAX.decode(cookieHeader);
        for (io.netty.handler.codec.http.cookie.Cookie cookie : cookies) {
            javax.servlet.http.Cookie c = new javax.servlet.http.Cookie(cookie.name(), cookie.value());

            if (cookie.domain() != null) {
                c.setDomain(cookie.domain());
            }/*  www  . j ava 2  s.  com*/

            c.setHttpOnly(cookie.isHttpOnly());
            c.setMaxAge((int) cookie.maxAge());
            if (cookie.path() != null) {
                c.setPath(cookie.path());
            }

            c.setSecure(cookie.isSecure());
            result.add(c);

        }
    }
    return result;
}

From source file:org.jooby.internal.netty.NettyRequest.java

License:Apache License

private org.jooby.Cookie cookie(final Cookie c) {
    org.jooby.Cookie.Definition cookie = new org.jooby.Cookie.Definition(c.name(), c.value());
    Optional.ofNullable(c.domain()).ifPresent(cookie::domain);
    Optional.ofNullable(c.path()).ifPresent(cookie::path);

    return cookie.toCookie();
}

From source file:org.robotbrains.support.web.server.netty.NettyHttpRequest.java

License:Apache License

/**
 * Convert a Netty cookie to a Java HTTP cookie.
 *
 * @param cookie/*from   ww  w. j a v  a 2 s .  c  o  m*/
 *          the Netty cookie
 *
 * @return the Java cookie
 */
private HttpCookie convertFromNettyCookie(Cookie cookie) {
    HttpCookie httpCookie = new HttpCookie(cookie.name(), cookie.value());
    httpCookie.setDomain(cookie.domain());
    httpCookie.setMaxAge(cookie.maxAge());
    httpCookie.setPath(cookie.path());
    httpCookie.setSecure(cookie.isSecure());

    return httpCookie;
}