Example usage for javax.servlet.http HttpServletRequest getHeaderNames

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

Introduction

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

Prototype

public Enumeration<String> getHeaderNames();

Source Link

Document

Returns an enumeration of all the header names this request contains.

Usage

From source file:com.threewks.thundr.bind.http.request.RequestHeaderBinder.java

@SuppressWarnings("unchecked")
private Map<String, String[]> createNormalisedHeaderMap(HttpServletRequest req) {
    Map<String, String[]> results = new HashMap<String, String[]>();
    Enumeration<String> headerNames = req.getHeaderNames();
    if (headerNames != null) {
        for (String name : Expressive.iterable(headerNames)) {
            String[] values = headerValues(req.getHeaders(name));
            results.put(normaliseHeaderName(name), values);
        }/*www. j a  v  a2 s .c  o m*/
    }
    return results;
}

From source file:de.bermuda.arquillian.example.ContentTypeProxyServlet.java

private void copyRequestHeaders(HttpServletRequest req, HttpMethod post) {
    Enumeration<String> headerNames = req.getHeaderNames();
    while (headerNames.hasMoreElements()) {
        String headerName = headerNames.nextElement();
        post.addRequestHeader(headerName, req.getHeader(headerName));
        log.info("Copying request header: " + headerName + ": " + req.getHeader(headerName));
    }//  w w  w  .  j a  v  a 2 s  . co  m
}

From source file:com.gopivotal.cloudfoundry.test.core.RuntimeUtils.java

public Map<String, List<String>> requestHeaders(HttpServletRequest request) {
    Map<String, List<String>> headers = new TreeMap<>();

    for (Enumeration<String> names = request.getHeaderNames(); names.hasMoreElements();) {
        String name = names.nextElement();
        headers.put(name, getValuesAsList(request.getHeaders(name)));
    }// w ww. j  ava 2 s  .  c  o  m

    return headers;
}

From source file:org.gwtwidgets.server.spring.test.serverimpl.DummyGWTRPCServiceExporter.java

private void printHeaders(HttpServletRequest request) {
    if (!log.isDebugEnabled())
        return;// w w w .  j a v  a2  s  . co m
    log.debug("Handling request with headers:");
    Enumeration<String> e = request.getHeaderNames();
    while (e.hasMoreElements()) {
        String name = e.nextElement().toString();
        String value = request.getHeader(name);
        log.debug(name + " = " + value);
    }
}

From source file:it.geosolutions.geostore.services.rest.security.GeoStoreRequestHeadersAuthenticationFilter.java

/**
 * Transform headers into a map.//w  w w.j ava 2 s .  c  o m
 * 
 * @param req
 * @return
 */
private Object getHeadersMap(HttpServletRequest req) {
    Map<String, String> headers = new HashMap<String, String>();
    Enumeration headerNames = req.getHeaderNames();
    while (headerNames.hasMoreElements()) {
        String headerName = headerNames.nextElement().toString();
        headers.put(cleanHeaderName(headerName), req.getHeader(headerName));
    }
    return headers;
}

From source file:org.openrepose.commons.utils.test.mocks.util.MocksUtil.java

public static RequestInformation servletRequestToRequestInformation(HttpServletRequest request, String body)
        throws IOException {

    RequestInformation req = new RequestInformation();

    req.setUri(request.getRequestURL().toString());
    req.setPath(request.getRequestURI());
    req.setMethod(request.getMethod());/*from  www  . ja va 2  s  .co  m*/
    req.setQueryString(request.getQueryString());
    req.setBody(body);

    if (!request.getParameterMap().isEmpty()) {
        QueryParameters q = new QueryParameters();
        Enumeration<String> queryParamNames = request.getParameterNames();
        while (queryParamNames.hasMoreElements()) {
            String name = queryParamNames.nextElement();
            String value = Arrays.toString(request.getParameterMap().get(name));
            NameValuePair nvp = new NameValuePair();
            nvp.setName(name);
            nvp.setValue(value);
            q.getParameter().add(nvp);
        }
        req.setQueryParams(q);
    }

    HeaderList h = new HeaderList();
    Enumeration<String> headerNames = request.getHeaderNames();
    while (headerNames.hasMoreElements()) {
        String headerName = headerNames.nextElement();
        Enumeration<String> headerValues = request.getHeaders(headerName);
        while (headerValues.hasMoreElements()) {
            String headerValue = headerValues.nextElement();
            NameValuePair nvp = new NameValuePair();
            nvp.setName(headerName);
            nvp.setValue(headerValue);
            h.getHeader().add(nvp);
        }
    }
    req.setHeaders(h);
    return req;
}

From source file:com.tbodt.jswerve.servlet.JSwerveServlet.java

private Headers translateHeaders(HttpServletRequest req) {
    Headers.Builder builder = Headers.builder();
    for (String headerName : Collections.list(req.getHeaderNames()))
        builder.header(headerName, req.getHeader(headerName));
    return builder.build();
}

From source file:edu.cornell.mannlib.vitro.webapp.controller.authenticate.LoginExternalAuthSetup.java

private void dumpRequestHeaders(HttpServletRequest req) {
    if (log.isDebugEnabled()) {
        @SuppressWarnings("unchecked")
        Enumeration<String> names = req.getHeaderNames();
        while (names.hasMoreElements()) {
            String name = names.nextElement();
            log.debug("header: " + name + "=" + req.getHeader(name));
        }//from  ww  w.ja v  a 2 s  .c o m
    }
}

From source file:org.openrepose.powerfilter.intrafilterlogging.RequestLog.java

private Map<String, String> convertRequestHeadersToMap(HttpServletRequest httpServletRequest) {
    Map<String, String> headerMap = new LinkedHashMap<>();
    List<String> headerNames = Collections.list(httpServletRequest.getHeaderNames());

    for (String headerName : headerNames) {
        StringJoiner stringJoiner = new StringJoiner(",");
        Collections.list(httpServletRequest.getHeaders(headerName)).forEach(stringJoiner::add);
        headerMap.put(headerName, stringJoiner.toString());
    }/*from  w  ww  . j  a  v a2 s .c om*/

    return headerMap;
}