/** * Construct a wrapper for the specified request. * * @param request The request to be wrapped */ publicXPanRequestWrapper(HttpServletRequest request)throws IOException { super(request); body = IOUtils.toByteArray(super.getInputStream()); }
@Override public BufferedReader getReader()throws IOException { returnnewBufferedReader(newInputStreamReader(getInputStream())); }
@Override public ServletInputStream getInputStream()throws IOException { returnnewRequestBodyCachingInputStream(body); }
@Override publicbooleanisReady() { // This implementation will never block // We also never need to call the readListener from this method, as this method will never return false return isFinished(); }
@Override publicvoidsetReadListener(ReadListener listener) { if (listener == null) { thrownewIllegalArgumentException("listener cann not be null"); } if (this.listener != null) { thrownewIllegalArgumentException("listener has been set"); } this.listener = listener; if (!isFinished()) { try { listener.onAllDataRead(); } catch (IOException e) { listener.onError(e); } } else { try { listener.onAllDataRead(); } catch (IOException e) { listener.onError(e); } } }