List of usage examples for javax.servlet ServletInputStream reset
public synchronized void reset() throws IOException
mark
method was last called on this input stream. From source file:org.openrepose.powerfilter.intrafilterlogging.RequestLog.java
public RequestLog(HttpServletRequest httpServletRequest, Filter filter) throws IOException { preamble = "Intrafilter Request Log"; timestamp = new DateTime().toString(); currentFilter = StringUtils.isEmpty(filter.getId()) ? filter.getName() : filter.getId() + "-" + filter.getName(); httpMethod = httpServletRequest.getMethod(); requestURI = httpServletRequest.getRequestURI(); headers = convertRequestHeadersToMap(httpServletRequest); try {//www.ja v a 2 s . co m ServletInputStream inputStream = httpServletRequest.getInputStream(); if (inputStream.markSupported()) { inputStream.mark(Integer.MAX_VALUE); requestBody = IOUtils.toString(inputStream); //http://stackoverflow.com/a/309448 inputStream.reset(); } else { LOG.warn("Unable to populate request body - {} does not support mark/reset.", inputStream); } } catch (IOException e) { LOG.warn("Unable to populate request body.", e); } }