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

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


      //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


        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

      // Encode the cookie.
      NSArray<WOCookie> wocookies = wrapping.cookies();
      if(!wocookies.isEmpty()) {
        CookieEncoder cookieEncoder = new CookieEncoder(true);
        for (WOCookie wocookie : wocookies) {
          Cookie cookie = asCookie(wocookie);
          cookieEncoder.addCookie(cookie);
        } return cookieEncoder.encode();
      } else return null;
    } else return wrapping.headerForKey(name);
  }
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

        for (Map.Entry<String, List<String>> header : headerFields.entrySet()) {
            if ("Set-Cookie".equals(header.getKey())) {
                List<String> value = header.getValue();
                for (String cookie : value) {
                    //since this processing is per header, there is only one cookie to parse
                    Cookie nettCookie = new CookieDecoder().decode(cookie).iterator().next();
                    HttpCookie c  = new HttpCookie(nettCookie.getName(),nettCookie.getValue());
                    cookies.add(c);
                }
            }
        }
        return sort(cookies);
View Full Code Here

TOP

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

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.