Example usage for javax.servlet.http HttpServletRequest getHeaders

List of usage examples for javax.servlet.http HttpServletRequest getHeaders

Introduction

In this page you can find the example usage for javax.servlet.http HttpServletRequest getHeaders.

Prototype

public Enumeration<String> getHeaders(String name);

Source Link

Document

Returns all the values of the specified request header as an Enumeration of String objects.

Usage

From source file:org.squashtest.tm.web.internal.exceptionresolver.ExceptionResolverUtils.java

public static boolean clientAcceptsMIME(HttpServletRequest request, MimeType type) {
    Enumeration<String> e = request.getHeaders(RequestHeaders.ACCEPT);
    while (e.hasMoreElements()) {
        String header = e.nextElement();
        if (StringUtils.containsIgnoreCase(StringUtils.trimToEmpty(header), type.requestHeaderValue())) {
            return true;
        }/*  w  w w. j  a v a2 s.c o  m*/
    }
    return false;
}

From source file:org.squashtest.tm.web.internal.exceptionresolver.ExceptionResolverUtils.java

public static boolean clientAcceptsMIMEOrAnything(HttpServletRequest request, MimeType type) {
    Enumeration<String> e = request.getHeaders(RequestHeaders.ACCEPT);
    while (e.hasMoreElements()) {
        String header = e.nextElement();
        if (StringUtils.containsIgnoreCase(StringUtils.trimToEmpty(header), type.requestHeaderValue())
                || StringUtils.containsIgnoreCase(StringUtils.trimToEmpty(header),
                        MimeType.ANYTHING.requestHeaderValue())) {
            return true;
        }//ww w.  j av a 2 s .  c om
    }
    return false;
}

From source file:org.ambraproject.wombat.util.ReproxyUtil.java

/**
 * Check whether a request supports reproxying.
 *
 * @param request a request//from w ww  . j ava  2  s. c o m
 * @return {@code true} if it supports reproxying
 */
private static boolean supportsReproxy(HttpServletRequest request) {
    Enumeration headers = request.getHeaders(X_PROXY_CAPABILITIES);
    if (headers != null) {
        while (headers.hasMoreElements()) {
            if (REPROXY_FILE.equals(headers.nextElement())) {
                return true;
            }
        }
    }
    return false;
}

From source file:org.jboss.aerogear.unifiedpush.rest.util.BearerHelper.java

public static Optional<String> getBarearToken(HttpServletRequest request) {
    return getBarearToken(request.getHeaders("Authorization"));
}

From source file:org.yestech.lib.web.RequestUtils.java

/**
 * Checks if request contains the header value.
 *
 * @return true if header acc/*from  w w w .  ja v  a2  s  .c  om*/
 */
public static boolean headerContains(final HttpServletRequest request, final String header,
        final String value) {

    logRequestHeaders(logger, request);

    final Enumeration accepted = request.getHeaders(header);
    while (accepted.hasMoreElements()) {
        final String headerValue = (String) accepted.nextElement();
        if (headerValue.indexOf(value) != -1) {
            return true;
        }
    }
    return false;
}

From source file:eu.morfeoproject.fast.catalogue.util.Util.java

/**
 * @return the list of values associated with a header. Never null.
 */// w w w . ja v a2 s.c om
public static List<String> getHeader(HttpServletRequest request, String hname) {
    List<String> values = new ArrayList<String>();

    Enumeration<?> hvals = request.getHeaders(hname.toString());
    while (hvals.hasMoreElements()) {
        String hval = String.valueOf(hvals.nextElement());
        values.add(hval);
    }

    return values;
}

From source file:com.yiji.openapi.sdk.util.Servlets.java

@SuppressWarnings("unchecked")
public static List<String> getHeaderValues(HttpServletRequest request, String name) {
    Enumeration<String> e = request.getHeaders(name);
    List<String> values = Lists.newArrayList();
    while (e.hasMoreElements()) {
        values.add(e.nextElement());/* www . j ava  2  s.com*/
    }
    return values;
}

From source file:com.threewks.thundr.request.servlet.ServletSupport.java

public static List<String> getHeaders(String name, HttpServletRequest req) {
    return Expressive.list(Expressive.iterable(req.getHeaders(name)));
}

From source file:net.jadler.stubbing.server.jetty.RequestUtils.java

private static Map<String, List<String>> converHeaders(HttpServletRequest request) {
    Map<String, List<String>> result = new HashMap<String, List<String>>();
    Enumeration headerNames = request.getHeaderNames();
    while (headerNames.hasMoreElements()) {
        String headerName = (String) headerNames.nextElement();
        result.put(headerName, list(request.getHeaders(headerName)));
    }/*from   w  w  w. j a  v a 2 s .  co  m*/

    return result;
}

From source file:scratch.simple.webapp.controller.PageController.java

private static void appendHeaders(StringBuilder builder, HttpServletRequest request) {

    final Enumeration<String> headerNames = request.getHeaderNames();

    while (headerNames.hasMoreElements()) {

        final String headerName = headerNames.nextElement();

        builder.append(headerName).append(": ");
        appendValues(builder, request.getHeaders(headerName));
    }/*w ww. ja v  a  2s .  c o m*/
}