@Override public ServletInputStream getInputStream() throws IOException { if (servletInputStream == null) { final InputStream in = bodyPipedStream.getInputStream(); servletInputStream = new ServletInputStream() { @Override public int read() throws IOException { return in.read(); } @Override public int available() throws IOException { return in.available(); } @Override public void close() throws IOException { in.close(); } public int read(byte[] b, int off, int len) throws IOException { return in.read(b, off, len); } }; } return servletInputStream; }
@Override public BufferedReader getReader() throws IOException { if (bufferedReader == null) { bufferedReader = new BufferedReader( new InputStreamReader(bodyPipedStream.getInputStream(), characterEncoding)); } return bufferedReader; }
/** if http method is POST or PUT, when the business process finish, it must close piped stream */ void releaseInputStreamData() { try { if (getContentLength() > 0) { if (bodyPipedStream != null) { bodyPipedStream.close(); } if (multipartFormData != null) { multipartFormData.close(); } } } catch (Throwable t) { log.error("release input stream error", t); } }