Java Code Examples for org.osgl.http.H#Cookie
The following examples show how to use
org.osgl.http.H#Cookie .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: LocaleResolver.java From actframework with Apache License 2.0 | 5 votes |
private Locale resolveFromSessionOrCookie() { Locale locale = null; H.Session session = context.session(); if (null != session) { locale = parseStr(session.get(KEY)); } if (null == locale) { H.Cookie cookie = context.cookie(config.localeCookieName()); locale = null == cookie ? null : parseStr(cookie.value()); } return locale; }
Example 2
Source File: LocaleResolver.java From actframework with Apache License 2.0 | 5 votes |
public void dissolve() { if (!shouldWriteLocaleCookie()) { return; } String cookieName = config.localeCookieName(); Locale locale = context.locale(); if (null == locale) { locale = this.locale; } String localeStr = locale.toString(); H.Session session = context.session(); if (null != session) { if (reset) { session.remove(KEY); } else { session.put(KEY, localeStr); } } H.Cookie cookie = new H.Cookie(cookieName, localeStr); cookie.domain(config.cookieDomain()); cookie.path("/"); // in case we have resolved locale from cookie and we shouldn't write cookie anymore, we need to clear it cookie.maxAge(reset ? -1 : COOKIE_TTL); if (reset) { cookie.expires(DateTime.now().minusDays(1).toDate()); } context.resp().addCookie(cookie); }
Example 3
Source File: CookieSessionMapper.java From actframework with Apache License 2.0 | 5 votes |
private void writeState(String state, String cookieName, H.Response response) { if (null == state) { return; } H.Cookie cookie = createCookie(cookieName, state); response.addCookie(cookie); }
Example 4
Source File: CookieSessionMapper.java From actframework with Apache License 2.0 | 5 votes |
private H.Cookie createCookie(String name, String value) { H.Cookie cookie = new H.Cookie(name, value); cookie.path("/"); cookie.domain(cookieDomain); cookie.httpOnly(true); cookie.secure(sessionSecure); if (sessionWillExpire && persistentSession) { cookie.maxAge(ttl); } return cookie; }
Example 5
Source File: ActProviders.java From actframework with Apache License 2.0 | 5 votes |
@Override public H.Cookie get(String s) { ActionContext ctx = ActionContext.current(); if (null == ctx) { return null; } H.Request req = ctx.req(); return null == req ? null : req.cookie(S.ensure(s).strippedOff("", "Cookie")); }
Example 6
Source File: ResponseCache.java From actframework with Apache License 2.0 | 5 votes |
public void applyTo(ActResponse response) { for (H.Cookie cookie : cookies.values()) { response.addCookie(cookie); } for (Map.Entry<String, String> entry : headers.entrySet()) { response.header(entry.getKey(), entry.getValue()); } if (null != contentType) { response.contentType(contentType); } if (null != charset) { response.characterEncoding(charset); } response.commitContentType(); if (null != len) { response.contentLength(len); } if (null != locale) { response.locale(locale); } if (null != status) { response.status(status); } if (null != buffer) { response.writeContent(buffer.duplicate()); } else if (null != osCache) { osCache.apply(response); } else if (null != writerCache) { writerCache.apply(response); } else if (null != outputCache) { outputCache.apply(response); } }
Example 7
Source File: UndertowCookieAdaptor.java From actframework with Apache License 2.0 | 4 votes |
public UndertowCookieAdaptor(H.Cookie cookie) { E.NPE(cookie); hc = cookie; }
Example 8
Source File: SessionMapper.java From actframework with Apache License 2.0 | 4 votes |
@Override public void serializeFlash(H.Cookie flashCookie, ActionContext context) { context.resp().header(flashHeaderName(), flashCookie.value()); }
Example 9
Source File: SessionMapper.java From actframework with Apache License 2.0 | 4 votes |
@Override public void serializeSession(H.Cookie sessionCookie, ActionContext context) { context.resp().header(sessionHeaderName(), sessionCookie.value()); }
Example 10
Source File: SessionMapper.java From actframework with Apache License 2.0 | 4 votes |
@Override public String deserializeFlash(ActionContext context) { H.Cookie flashCookie = context.req().cookie(context.config().flashCookieName()); return null == flashCookie ? null : flashCookie.value(); }
Example 11
Source File: SessionMapper.java From actframework with Apache License 2.0 | 4 votes |
@Override public String deserializeSession(ActionContext context) { H.Cookie sessionCookie = context.req().cookie(context.config().sessionCookieName()); return null == sessionCookie ? null : sessionCookie.value(); }
Example 12
Source File: SessionMapper.java From actframework with Apache License 2.0 | 4 votes |
@Override public void serializeFlash(H.Cookie flashCookie, ActionContext context) { context.resp().addCookie(flashCookie); }
Example 13
Source File: SessionMapper.java From actframework with Apache License 2.0 | 4 votes |
@Override public void serializeSession(H.Cookie sessionCookie, ActionContext context) { context.resp().addCookie(sessionCookie); }
Example 14
Source File: ActionContext.java From actframework with Apache License 2.0 | 4 votes |
public H.Cookie cookie(String name) { return req().cookie(name); }
Example 15
Source File: ResponseCache.java From actframework with Apache License 2.0 | 4 votes |
@Override public void addCookie(H.Cookie cookie) { realResponse.addCookie(cookie); cookies.put(cookie.name(), cookie); }
Example 16
Source File: CookieSessionMapper.java From actframework with Apache License 2.0 | 4 votes |
private String readState(String cookieName, H.Request request) { H.Cookie cookie = request.cookie(cookieName); return null == cookie ? null : cookie.value(); }
Example 17
Source File: MockResponse.java From actframework with Apache License 2.0 | 2 votes |
@Override public void addCookie(H.Cookie cookie) { }
Example 18
Source File: MockResponse.java From actframework with Apache License 2.0 | 2 votes |
@Override public void addCookie(H.Cookie cookie) { }
Example 19
Source File: SessionMapper.java From actframework with Apache License 2.0 | votes |
void serializeFlash(H.Cookie flashCookie, ActionContext context);
Example 20
Source File: SessionMapper.java From actframework with Apache License 2.0 | votes |
void serializeSession(H.Cookie sessionCookie, ActionContext context);