Example usage for com.google.common.net HttpHeaders COOKIE

List of usage examples for com.google.common.net HttpHeaders COOKIE

Introduction

In this page you can find the example usage for com.google.common.net HttpHeaders COOKIE.

Prototype

String COOKIE

To view the source code for com.google.common.net HttpHeaders COOKIE.

Click Source Link

Document

The HTTP Cookie header field name.

Usage

From source file:com.zimbra.cs.dav.service.DavServlet.java

public static StringBuilder addResponseHeaderLoggingInfo(HttpServletResponse resp, StringBuilder sb) {
    if (!ZimbraLog.dav.isDebugEnabled()) {
        return sb;
    }/*ww w. j ava 2 s .  c o  m*/
    sb.append("DAV RESPONSE:\n");
    String statusLine = DavResponse.sStatusTextMap.get(resp.getStatus());
    if (statusLine != null) {
        sb.append(statusLine);
    } else {
        sb.append("HTTP/1.1 ").append(resp.getStatus());
    }
    Collection<String> hdrNames = resp.getHeaderNames();
    if (hdrNames != null && !hdrNames.isEmpty()) {
        for (String hdrName : hdrNames) {
            if (hdrName.contains("Auth") || (hdrName.contains(HttpHeaders.COOKIE))) {
                sb.append("\n").append(hdrName).append(": *** REPLACED ***");
                continue;
            }
            Collection<String> vals = resp.getHeaders(hdrName);
            for (String val : vals) {
                sb.append("\n").append(hdrName).append(": ").append(val);
            }
        }
    }
    sb.append("\n\n");
    return sb;
}

From source file:com.tinspx.util.net.Cookies.java

/**
 * Fixes the Cookie and Cookie2 headers to ensure there is only one mapping
 * for each cookie header. Changes are made directly in the provided map.
 * <p>//w ww  .  j a v  a 2s . co  m
 * If there are multiple mappings to either the Cookie or Cookie2 header,
 * they are combined into a single String delimited by the String "; "
 * (semicolon followed by space).
 *
 * @param headers the existing headers to fix
 * @return true if {@code headers} was modified
 */
public static boolean fixCookieHeaders(Map<String, List<String>> headers) {
    boolean modified = false;
    List<String> h = headers.get(HttpHeaders.COOKIE);
    if (h != null && h.size() > 1) {
        headers.put(HttpHeaders.COOKIE, toSingleCookieList(h));
        modified = true;
    }
    h = headers.get(COOKIE2);
    if (h != null && h.size() > 1) {
        headers.put(COOKIE2, toSingleCookieList(h));
        modified = true;
    }
    return modified;
}