List of usage examples for javax.servlet.http HttpServletRequestWrapper getHeaders
@Override
public Enumeration<String> getHeaders(String name)
From source file:org.bessle.neo4j.proxy.HttpRequestLoggingFilter.java
protected Map<String, Object> getTrace(HttpServletRequestWrapper wrappedRequest) { Map<String, Object> headers = new LinkedHashMap<String, Object>(); Enumeration<String> names = wrappedRequest.getHeaderNames(); while (names.hasMoreElements()) { String name = names.nextElement(); List<String> values = Collections.list(wrappedRequest.getHeaders(name)); Object value = values;// w ww. ja va 2 s .c o m if (values.size() == 1) { value = values.get(0); } else if (values.isEmpty()) { value = ""; } headers.put(name, value); } Map<String, Object> trace = new LinkedHashMap<String, Object>(); Map<String, Object> allHeaders = new LinkedHashMap<String, Object>(); allHeaders.put("request", headers); trace.put("method", wrappedRequest.getMethod()); trace.put("path", wrappedRequest.getRequestURI()); trace.put("headers", allHeaders); Throwable exception = (Throwable) wrappedRequest.getAttribute("javax.servlet.error.exception"); if (exception != null && this.errorAttributes != null) { RequestAttributes requestAttributes = new ServletRequestAttributes(wrappedRequest); Map<String, Object> error = this.errorAttributes.getErrorAttributes(requestAttributes, true); trace.put("error", error); } String body = "unknown"; try { //body = IOUtils.toString(wrappedRequest.getInputStream(), "UTF-8"); trace.put("body", body); InputStream wrappedInputStream = IOUtils.toInputStream(body, "UTF-8"); //wrappedRequest. } catch (IOException ioe) { trace.put("body", "untraceable"); } return trace; }