Search in sources :

Example 1 with RouterCookie

use of org.webpieces.ctx.api.RouterCookie in project webpieces by deanhiller.

the class ResponseCreator method addCommonHeaders.

public void addCommonHeaders(Http2Request request, Http2Response response, boolean isInternalError, boolean isDynamicPartOfWebsite) {
    String connHeader = request.getSingleHeaderValue(Http2HeaderName.CONNECTION);
    DateTime now = DateTime.now().toDateTime(DateTimeZone.UTC);
    String dateStr = formatter.print(now) + " GMT";
    //in general, nearly all these headers are desired..
    Http2Header date = new Http2Header(Http2HeaderName.DATE, dateStr);
    response.addHeader(date);
    if (isDynamicPartOfWebsite) {
        List<RouterCookie> cookies = createCookies(isInternalError);
        for (RouterCookie c : cookies) {
            Http2Header cookieHeader = create(c);
            response.addHeader(cookieHeader);
        }
    }
    if (connHeader == null)
        return;
    else if (!"keep-alive".equals(connHeader))
        return;
    //just re-use the connHeader from the request...
    response.addHeader(request.getHeaderLookupStruct().getHeader(Http2HeaderName.CONNECTION));
}
Also used : Http2Header(com.webpieces.http2parser.api.dto.lib.Http2Header) RouterCookie(org.webpieces.ctx.api.RouterCookie) DateTime(org.joda.time.DateTime)

Example 2 with RouterCookie

use of org.webpieces.ctx.api.RouterCookie in project webpieces by deanhiller.

the class RouterServiceImpl method copy.

private Map<String, RouterCookie> copy(Map<String, String> cookies) {
    Map<String, RouterCookie> map = new HashMap<>();
    for (Entry<String, String> entry : cookies.entrySet()) {
        RouterCookie c = copy(entry.getKey(), entry.getValue());
        map.put(c.name, c);
    }
    return map;
}
Also used : HashMap(java.util.HashMap) RouterCookie(org.webpieces.ctx.api.RouterCookie)

Example 3 with RouterCookie

use of org.webpieces.ctx.api.RouterCookie in project webpieces by deanhiller.

the class CookieTranslator method createBase.

private RouterCookie createBase(String name, Integer maxAge) {
    RouterCookie cookie = new RouterCookie();
    cookie.name = name;
    cookie.domain = null;
    cookie.path = "/";
    cookie.maxAgeSeconds = maxAge;
    cookie.isHttpOnly = isCookiesHttpOnly;
    cookie.isSecure = isCookiesSecure;
    cookie.value = "";
    return cookie;
}
Also used : RouterCookie(org.webpieces.ctx.api.RouterCookie)

Example 4 with RouterCookie

use of org.webpieces.ctx.api.RouterCookie in project webpieces by deanhiller.

the class RequestStreamWriter method copy.

private Map<String, RouterCookie> copy(Map<String, String> cookies) {
    Map<String, RouterCookie> map = new HashMap<>();
    for (Entry<String, String> entry : cookies.entrySet()) {
        RouterCookie c = copy(entry.getKey(), entry.getValue());
        map.put(c.name, c);
    }
    return map;
}
Also used : HashMap(java.util.HashMap) RouterCookie(org.webpieces.ctx.api.RouterCookie)

Example 5 with RouterCookie

use of org.webpieces.ctx.api.RouterCookie in project webpieces by deanhiller.

the class ResponseCreator method addDeleteCookie.

public void addDeleteCookie(Http2Response response, String badCookieName) {
    RouterCookie cookie = cookieTranslator.createDeleteCookie(badCookieName);
    Http2Header cookieHeader = create(cookie);
    response.addHeader(cookieHeader);
}
Also used : Http2Header(com.webpieces.http2parser.api.dto.lib.Http2Header) RouterCookie(org.webpieces.ctx.api.RouterCookie)

Aggregations

RouterCookie (org.webpieces.ctx.api.RouterCookie)12 HashMap (java.util.HashMap)3 Http2Header (com.webpieces.http2.api.dto.lowlevel.lib.Http2Header)2 Http2Header (com.webpieces.http2parser.api.dto.lib.Http2Header)2 SecureCookie (org.webpieces.router.impl.ctx.SecureCookie)2 Http2Response (com.webpieces.http2.api.dto.highlevel.Http2Response)1 DateTime (org.joda.time.DateTime)1 BadCookieException (org.webpieces.router.api.exceptions.BadCookieException)1 CookieTooLargeException (org.webpieces.router.api.exceptions.CookieTooLargeException)1 CookieScopeImpl (org.webpieces.router.impl.ctx.CookieScopeImpl)1 SecretKeyInfo (org.webpieces.util.security.SecretKeyInfo)1