List of usage examples for javax.servlet ServletInputStream mark
public synchronized void mark(int readlimit)
From source file:com.ebay.pulsar.metric.servlet.MetricRestServlet.java
@Override public void service(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { ServletInputStream inputStream = request.getInputStream(); if (inputStream != null) { inputStream.mark(Integer.MAX_VALUE); }/*from w ww. ja v a 2 s .c o m*/ try { String pathInfo = request.getPathInfo(); if (pathInfo.startsWith(PATH_PING)) { ping(request, pathInfo, response); } else if (pathInfo.startsWith(PATH_COUNTER)) { stats.incQueryRequestCount(); getCounters(request, pathInfo, response); } else if (pathInfo.startsWith(PATH_METRICGROUP)) { stats.incQueryRequestCount(); getMetrics(request, pathInfo, response); } else { stats.incInvalidRequestCount(); response.setStatus(HttpServletResponse.SC_NOT_FOUND); } } catch (Throwable ex) { String requestTxt = readRequest(request); stats.setLastFailedRequest(readRequestHead(request) + requestTxt); stats.registerError(ex); response.setStatus(HttpServletResponse.SC_INTERNAL_SERVER_ERROR); } finally { response.addHeader("Access-Control-Allow-Origin", "*"); response.addHeader("Access-Control-Allow-Methods", "*"); response.addHeader("Access-Control-Allow-Headers", "Content-Type"); } }
From source file:com.ebay.pulsar.collector.servlet.IngestServlet.java
@Override public void service(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { ServletInputStream inputStream = request.getInputStream(); if (inputStream != null) { inputStream.mark(Integer.MAX_VALUE); }// w w w . j a v a2s .c o m try { String pathInfo = request.getPathInfo(); if (pathInfo.startsWith(PATH_INGEST)) { stats.incIngestRequestCount(); add(request, pathInfo, response); } else if (pathInfo.startsWith(PATH_BATCH_INGEST)) { stats.incBatchIngestRequestCount(); batchAdd(request, pathInfo, response); } else { stats.incInvalidRequestCount(); response.setStatus(HttpServletResponse.SC_NOT_FOUND); } } catch (Throwable ex) { String requestTxt = readRequest(request); stats.setLastFailedRequest(readRequestHead(request) + requestTxt); stats.registerError(ex); response.setStatus(HttpServletResponse.SC_INTERNAL_SERVER_ERROR); } }
From source file:org.apache.falcon.resource.AbstractInstanceManager.java
private Properties getProperties(HttpServletRequest request) throws IOException { Properties props = new Properties(); ServletInputStream xmlStream = request == null ? null : request.getInputStream(); if (xmlStream != null) { if (xmlStream.markSupported()) { xmlStream.mark(XML_DEBUG_LEN); // mark up to debug len }//from w w w . j a v a 2 s . c om props.load(xmlStream); } return props; }
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 {//from w w w . ja va 2 s . c o 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); } }