@Test public void testReadFromInputStream() throws Exception{ ServletInputStream sis = request.getInputStream(); byte[] buff = new byte[TestGzipMessageResponse.TEST_STRING.getBytes().length]; sis.read(buff); Assert.assertEquals("Expected String output.", TestGzipMessageResponse.TEST_STRING, new String(buff)); Assert.assertEquals("There should be no more bytes in stream.", 0, streamBytes.remaining()); }
@Override public ServletInputStream getInputStream() throws IOException{ if(returnedReader != null){ throw new IllegalStateException("Method getReader() has already been called."); } if(returnedStream == null){ returnedStream = new GzipServletInputStream(super.getInputStream()); } return returnedStream; }
GzipMessageRequest extends HttpServletRequestWrapper { @Override public ServletInputStream getInputStream() throws IOException{ if(returnedReader != null){ throw new IllegalStateException("Method getReader() has already been called."); } if(returnedStream == null){ returnedStream = new GzipServletInputStream(super.getInputStream()); } return returnedStream; } }
GzipMessageRequest extends HttpServletRequestWrapper { @Override public ServletInputStream getInputStream() throws IOException{ if(returnedReader != null){ throw new IllegalStateException("Method getReader() has already been called."); } if(returnedStream == null){ returnedStream = new GzipServletInputStream(super.getInputStream()); } return returnedStream; } GzipMessageRequest(HttpServletRequest request); }
GzipMessageRequest extends HttpServletRequestWrapper { @Override public ServletInputStream getInputStream() throws IOException{ if(returnedReader != null){ throw new IllegalStateException("Method getReader() has already been called."); } if(returnedStream == null){ returnedStream = new GzipServletInputStream(super.getInputStream()); } return returnedStream; } GzipMessageRequest(HttpServletRequest request); @Override ServletInputStream getInputStream(); @Override BufferedReader getReader(); }
GzipMessageRequest extends HttpServletRequestWrapper { @Override public ServletInputStream getInputStream() throws IOException{ if(returnedReader != null){ throw new IllegalStateException("Method getReader() has already been called."); } if(returnedStream == null){ returnedStream = new GzipServletInputStream(super.getInputStream()); } return returnedStream; } GzipMessageRequest(HttpServletRequest request); @Override ServletInputStream getInputStream(); @Override BufferedReader getReader();  }