List of usage examples for javax.servlet.http HttpServletRequest getHeaderNames
public Enumeration<String> getHeaderNames();
From source file:hr.fer.zemris.vhdllab.web.LogRequestHeadersFilter.java
@Override protected void beforeRequest(HttpServletRequest request, String message) { if (logger.isDebugEnabled()) { Enumeration<?> headerNames = request.getHeaderNames(); StringBuilder sb = new StringBuilder(2000); sb.append("Request headers for uri: ").append(request.getRequestURI()); sb.append("\n"); while (headerNames.hasMoreElements()) { String name = (String) headerNames.nextElement(); String value = request.getHeader(name); sb.append(name).append(":").append(value).append("\n"); }/*w w w . j a va 2 s .c o m*/ logger.debug(sb.toString()); } }
From source file:org.nuxeo.wss.servlet.HttpServletRequestWrapper.java
public HttpServletRequestWrapper(HttpServletRequest request) { super(request); for (Enumeration<?> e = request.getHeaderNames(); e.hasMoreElements();) { String headerName = String.valueOf(e.nextElement()); if (StringUtils.isNotEmpty(headerName)) { String value = request.getHeader(headerName); headers.put(headerName.toLowerCase(), value); }//from www . j a v a2 s . c om } }
From source file:com.redhat.rhn.frontend.servlets.DumpFilter.java
private void logHeaders(HttpServletRequest req) { Enumeration items = req.getHeaderNames(); while (items.hasMoreElements()) { String name = (String) items.nextElement(); Enumeration hdrs = req.getHeaders(name); while (hdrs.hasMoreElements()) { log.debug("Header: name [" + name + "] value [" + (String) hdrs.nextElement() + "]"); }//from w ww . j av a2 s .c om } }
From source file:com.adaptris.core.http.jetty.MetadataHeaderHandler.java
private void handleHeaders(AdaptrisMessage message, HttpServletRequest request, String itemPrefix) { String prefix = defaultIfEmpty(itemPrefix, ""); for (Enumeration<String> e = request.getHeaderNames(); e.hasMoreElements();) { String key = (String) e.nextElement(); String value = request.getHeader(key); String metadataKey = prefix + key; log.trace("Adding Metadata [{}: {}]", metadataKey, value); message.addMetadata(prefix + key, value); }//from w w w . ja v a 2 s . c o m }
From source file:org.immopoly.appengine.ExposeCronjobServlet.java
private void logHeaders(HttpServletRequest req) { Enumeration en = req.getHeaderNames(); while (en.hasMoreElements()) { String header = en.nextElement().toString(); LOG.info("header" + header + " : " + req.getHeader(header).toString()); }//from www. ja va 2 s. c o m }
From source file:com.adaptris.core.http.jetty.ObjectMetadataHeaderHandler.java
private void handleHeaders(AdaptrisMessage message, HttpServletRequest request, String itemPrefix) { String prefix = defaultIfEmpty(itemPrefix, ""); for (Enumeration<String> e = request.getHeaderNames(); e.hasMoreElements();) { String key = (String) e.nextElement(); String value = request.getHeader(key); String metadataKey = prefix + key; log.trace("Adding Object Metadata [{}: {}]", metadataKey, value); message.addObjectHeader(metadataKey, value); }/*from ww w .j av a2 s . co m*/ }
From source file:com.sixt.service.framework.jetty.RpcReadException.java
public String toJson(HttpServletRequest req) { JsonObject obj = new JsonObject(); Enumeration<String> h = req.getHeaderNames(); while (h.hasMoreElements()) { String hKey = h.nextElement(); String hValue = req.getHeader(hKey); obj.addProperty("request_header_" + hKey, hValue); }/* w w w . j av a 2s .c om*/ obj.addProperty("exception_message", this.getMessage()); obj.addProperty("request_query_string", req.getQueryString()); obj.addProperty("request_url", req.getRequestURL().toString()); obj.addProperty("request_remote_addr", req.getRemoteAddr()); obj.addProperty("request_remote_port", req.getRemotePort()); obj.addProperty("request_remote_host", req.getRemoteHost()); obj.addProperty("request_remote_user", req.getRemoteUser()); String readBody = "success"; // read the whole remaining body and put the joined base64 encoded message into the json object try { byte[] ba = IOUtils.toByteArray(this.in); byte[] combined; if ((ba != null) && (this.incomplete != null)) { combined = new byte[ba.length + this.incomplete.length]; System.arraycopy(incomplete, 0, combined, 0, this.incomplete.length); System.arraycopy(ba, 0, combined, this.incomplete.length, ba.length); obj.addProperty("request_body", Base64.getEncoder().encodeToString(combined)); } else if (ba != null) { combined = ba; } else if (this.incomplete != null) { combined = this.incomplete; } else { readBody = "body is empty"; } } catch (Exception ex) { readBody = String.format("failed because: %s", ex.getCause()); } obj.addProperty("read_body", readBody); return obj.toString(); }
From source file:org.red5.server.net.servlet.RequestDumpServlet.java
/** {@inheritDoc} */ @Override/*from ww w.j av a 2 s.c o m*/ protected void service(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { Enumeration en = req.getHeaderNames(); while (en.hasMoreElements()) { String name = (String) en.nextElement(); log.info(name + " => " + req.getHeader(name)); } ByteBuffer reqBuffer = null; try { //req.getSession().getAttribute(REMOTING_CONNECTOR); reqBuffer = ByteBuffer.allocate(req.getContentLength()); ServletUtils.copy(req.getInputStream(), reqBuffer.asOutputStream()); //reqBuffer.flip(); log.info(HexDump.formatHexDump(reqBuffer.getHexDump())); } catch (IOException e) { log.error(e); } log.info("End"); }
From source file:org.apache.hadoop.gateway.dispatch.AbstractGatewayDispatch.java
public void copyRequestHeaderFields(HttpUriRequest outboundRequest, HttpServletRequest inboundRequest) { Enumeration<String> headerNames = inboundRequest.getHeaderNames(); while (headerNames.hasMoreElements()) { String name = headerNames.nextElement(); if (!outboundRequest.containsHeader(name) && !getOutboundRequestExcludeHeaders().contains(name)) { String value = inboundRequest.getHeader(name); outboundRequest.addHeader(name, value); }/*w w w.j a va 2 s .co m*/ } }
From source file:org.commonjava.indy.core.model.StoreHttpExchangeMetadata.java
private void populateHeaders(final Map<String, List<String>> headerMap, final HttpServletRequest request) { if (request == null) { return;// w w w.j a va2 s . c o m } Enumeration<String> en = request.getHeaderNames(); while (en.hasMoreElements()) { String name = en.nextElement(); List<String> values = headerMap.get(name); if (values == null) { values = new ArrayList<String>(); headerMap.put(name.toUpperCase(), values); } values.add(request.getHeader(name)); } }