| | |
| | | * |
| | | * @author ruoyi |
| | | */ |
| | | public class RepeatedlyRequestWrapper extends HttpServletRequestWrapper |
| | | { |
| | | public class RepeatedlyRequestWrapper extends HttpServletRequestWrapper { |
| | | private final byte[] body; |
| | | |
| | | public RepeatedlyRequestWrapper(HttpServletRequest request, ServletResponse response) throws IOException |
| | | { |
| | | public RepeatedlyRequestWrapper(HttpServletRequest request, ServletResponse response) throws IOException { |
| | | super(request); |
| | | request.setCharacterEncoding("UTF-8"); |
| | | response.setCharacterEncoding("UTF-8"); |
| | |
| | | } |
| | | |
| | | @Override |
| | | public BufferedReader getReader() throws IOException |
| | | { |
| | | public BufferedReader getReader() throws IOException { |
| | | return new BufferedReader(new InputStreamReader(getInputStream())); |
| | | } |
| | | |
| | | @Override |
| | | public ServletInputStream getInputStream() throws IOException |
| | | { |
| | | public ServletInputStream getInputStream() throws IOException { |
| | | final ByteArrayInputStream bais = new ByteArrayInputStream(body); |
| | | return new ServletInputStream() |
| | | { |
| | | return new ServletInputStream() { |
| | | @Override |
| | | public int read() throws IOException |
| | | { |
| | | public int read() throws IOException { |
| | | return bais.read(); |
| | | } |
| | | |
| | | @Override |
| | | public int available() throws IOException |
| | | { |
| | | public int available() throws IOException { |
| | | return body.length; |
| | | } |
| | | |
| | | @Override |
| | | public boolean isFinished() |
| | | { |
| | | public boolean isFinished() { |
| | | return false; |
| | | } |
| | | |
| | | @Override |
| | | public boolean isReady() |
| | | { |
| | | public boolean isReady() { |
| | | return false; |
| | | } |
| | | |
| | | @Override |
| | | public void setReadListener(ReadListener readListener) |
| | | { |
| | | public void setReadListener(ReadListener readListener) { |
| | | |
| | | } |
| | | }; |