List of usage examples for javax.servlet.http HttpServletRequest getHeaderNames
public Enumeration<String> getHeaderNames();
From source file:org.tsugi.http.HttpUtil.java
public static void printHeaders(HttpServletRequest request) { Enumeration<String> headerNames = request.getHeaderNames(); System.out.println("Headers for " + request.getRequestURI()); while (headerNames.hasMoreElements()) { String headerName = headerNames.nextElement(); System.out.println("Header Name - " + headerName + ", Value - " + request.getHeader(headerName)); }//from w w w . j a va 2s. co m }
From source file:de.adorsys.oauth.authdispatcher.matcher.BasicAuthAuthenticatorMatcher.java
private static boolean isBasicAuthentication(HttpServletRequest httpServletRequest) { for (String name : Collections.list(httpServletRequest.getHeaderNames())) { if ("authorization".equalsIgnoreCase(name)) { return httpServletRequest.getHeader(name).substring(0, 5).equalsIgnoreCase("Basic"); }/*from w w w. ja v a2 s. co m*/ } return false; }
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 ww .j a va 2s. c om*/ return result; }
From source file:gov.nih.nci.cabig.ctms.web.WebTools.java
@SuppressWarnings({ "unchecked" }) public static SortedMap<String, String[]> headersToMap(final HttpServletRequest request) { return namedAttributesToMap(request.getHeaderNames(), new AttributeAccessor<String[]>() { @SuppressWarnings({ "unchecked" }) public String[] getAttribute(String headerName) { Enumeration<String> values = request.getHeaders(headerName); List<String> valList = new ArrayList<String>(); while (values.hasMoreElements()) { valList.add(values.nextElement()); }//from w w w .j a va2 s . c o m return valList.toArray(new String[valList.size()]); } }); }
From source file:org.candlepin.common.filter.ServletLogger.java
public static StringBuilder logHeaders(HttpServletRequest req) { Enumeration<?> headerNames = req.getHeaderNames(); StringBuilder builder = new StringBuilder(); while (headerNames.hasMoreElements()) { String headerName = (String) headerNames.nextElement(); builder.append(headerName).append(": ").append(req.getHeader(headerName)).append("\n"); }/*from w w w .j av a 2 s.co m*/ builder.append("---\n"); return builder; }
From source file:org.scilla.util.PartialContentHandler.java
private static void logHeaders(HttpServletRequest request) { for (Enumeration en = request.getHeaderNames(); en.hasMoreElements();) { String key = (String) en.nextElement(); String val = request.getHeader(key); log.debug("header: " + key + "=" + val); }/*from w w w . j av a 2 s . c o m*/ }
From source file:oeg.licensius.service.ServiceCommons.java
/** * Determines whether a HTTP Servlet Request is demanding Turtle * * @param request HTTP request//from w w w. j av a 2 s. co m * @retur true if demanding turtle */ public static boolean isJSON(HttpServletRequest request) { String uri = request.getRequestURI(); Enumeration enume = request.getHeaderNames(); while (enume.hasMoreElements()) { String hname = (String) enume.nextElement(); Enumeration<String> enum2 = request.getHeaders(hname); while (enum2.hasMoreElements()) { String valor = enum2.nextElement(); if (hname.equals("Accept")) { if (valor.contains("application/json")) { return true; } } } } return false; }
From source file:net.siegmar.japtproxy.JaptProxyServlet.java
/** * Logs the header of the incoming request. * * @param req the HttpServletRequest object */// w ww .j a v a 2 s. c om private static void logHeader(final HttpServletRequest req) { final Enumeration<String> headers = req.getHeaderNames(); final StringBuilder sb = new StringBuilder(); while (headers.hasMoreElements()) { final String headerName = headers.nextElement(); sb.append(headerName); sb.append('='); sb.append(req.getHeader(headerName)); if (headers.hasMoreElements()) { sb.append(','); } } LOG.debug("Request header: {}", sb); }
From source file:mojo.view.util.DebugUtils.java
@SuppressWarnings("rawtypes") public static void logRequestHeaders(HttpServletRequest req) { logger.debug("REQUEST HEADERS"); logger.debug("---------------"); Enumeration enums = req.getHeaderNames(); while (enums.hasMoreElements()) { String headerName = (String) enums.nextElement(); String headerValue = req.getHeader(headerName); logger.debug(headerName + ": " + headerValue); }//from w w w . j ava 2s.co m logger.debug(""); }
From source file:com.qatickets.common.HttpUtils.java
public static Map<String, String> getHeadersAsMap(HttpServletRequest req) { final Map<String, String> headers = new HashMap<String, String>(); final Enumeration enames = req.getHeaderNames(); while (enames.hasMoreElements()) { final String name = (String) enames.nextElement(); final String value = req.getHeader(name); headers.put(name, value);/*from w w w .j ava2 s .c o m*/ } return headers; }