Package org.jboss.netty.handler.codec.http

Examples of org.jboss.netty.handler.codec.http.DefaultCookie


      //destroy the session.
      if (sessionId == null) {
        return;
      }
      CookieEncoder cookieEncoder = new CookieEncoder(true);
      Cookie cookie = new DefaultCookie(SESSION, "deleted");
      cookie.setMaxAge(0);
      cookieEncoder.addCookie(cookie);
          controller.getResponse().setHeader(HttpHeaders.Names.SET_COOKIE, cookieEncoder.encode());
          this.getSessionPersistence(controller).deleteSession(sessionId);
      return;
    }
   
   
    if (sessionId == null && !controller.getSessionStorage().isEmpty()) {
      CookieEncoder cookieEncoder = new CookieEncoder(true);
      sessionId = UUID.randomUUID().toString();
      Cookie cookie = new DefaultCookie(SESSION, sessionId);
      cookie.setMaxAge(this.maxAge);
      cookieEncoder.addCookie(cookie);
          controller.getResponse().setHeader(HttpHeaders.Names.SET_COOKIE, cookieEncoder.encode());
    }
    //save the session.
    controller.getSessionStorage().put("expires", IsoDateUtil.getIsoDate(new Date(new Date().getTime()+(1000*this.maxAge))));
 
View Full Code Here


                Iterator<Cookie> ic = request.getCookies().iterator();
                Cookie c;
                org.jboss.netty.handler.codec.http.Cookie cookie;
                while (ic.hasNext()) {
                    c = ic.next();
                    cookie = new DefaultCookie(c.getName(), c.getValue());
                    cookie.setPath(c.getPath());
                    cookie.setMaxAge(c.getMaxAge());
                    cookie.setDomain(c.getDomain());
                    httpCookieEncoder.addCookie(cookie);
                }
View Full Code Here

        return response.containsHeader(name);
    }

    @Override
    public NettyHttpResponse cookie(HttpCookie httpCookie) {
        Cookie nettyCookie = new DefaultCookie(httpCookie.getName(),httpCookie.getValue());
        nettyCookie.setDomain(httpCookie.getDomain());
        nettyCookie.setPath(httpCookie.getPath());
        nettyCookie.setSecure(httpCookie.getSecure());
        nettyCookie.setMaxAge((int)httpCookie.getMaxAge());
        nettyCookie.setVersion(httpCookie.getVersion());
        nettyCookie.setDiscard(httpCookie.getDiscard());
        nettyCookie.setHttpOnly(true);
        CookieEncoder encoder = new CookieEncoder(true);
        encoder.addCookie(nettyCookie);
        return header(HttpHeaders.Names.SET_COOKIE, encoder.encode());
    }
View Full Code Here

                        .content(body)
                        .end();
            }
        }).start().get();
        URLConnection urlConnection = httpGet(webServer, "/");
        Cookie t = new DefaultCookie("a", "b");
        t.setMaxAge(5000);
        t.setSecure(true);
        t.setPath("/path");
        CookieEncoder e = new CookieEncoder(true);
        e.addCookie(t);
        urlConnection.addRequestProperty("Cookie", e.encode());
        String s = new HttpCookie("c", "d").toString();
        urlConnection.addRequestProperty("Cookie", s + "; " + new HttpCookie("e", "f").toString());
View Full Code Here

TOP

Related Classes of org.jboss.netty.handler.codec.http.DefaultCookie

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.