List of usage examples for com.google.common.net HttpHeaders VARY
String VARY
To view the source code for com.google.common.net HttpHeaders VARY.
Click Source Link
From source file:com.sector91.wit.http.CsrfInterceptor.java
public static String csrfToken(Request request, Response response) { final CookieParams params = (CookieParams) request.getAttribute(CookieParams.class); if (params == null) throw new IllegalStateException( "Cannot use CsrfInterceptor.csrfToken()" + " on a route that does not have a CsrfInterceptor."); Cookie cookie = request.getCookie(params.name); String token;/*from w ww .j a va 2 s . c om*/ if (cookie == null) { // Generate the token if it's not already stored in a cookie. Log.trace(TAG, "Creating new CSRF token."); token = generateToken(); cookie = new Cookie(params.name, token); if (params.domain != null) cookie.setDomain(params.domain); if (params.path != null) cookie.setPath(params.path); cookie.setSecure(params.secure); cookie.setProtected(params.httpOnly); response.setCookie(cookie); } else { token = cookie.getValue(); } response.addValue(HttpHeaders.VARY, "Cookie"); return token; }
From source file:org.obm.push.impl.ResponderImpl.java
private OutputStream getOutputStream(boolean gzip) throws IOException { OutputStream out = null;//from ww w .java 2 s . c om try { out = resp.getOutputStream(); if (gzip) { resp.addHeader(HttpHeaders.VARY, HttpHeaders.ACCEPT_ENCODING); resp.addHeader(HttpHeaders.CONTENT_ENCODING, "gzip"); return new GZIPOutputStream(out); } else { return out; } } catch (IOException t) { IOUtils.closeQuietly(out); throw t; } catch (RuntimeException e) { IOUtils.closeQuietly(out); throw e; } }