IoUtil { public static String readRequestBody(HttpServletRequest request) throws IOException { InputStream inputStream = getRequestInputStream(request); return inputStream != null ? IoUtil.readStream(inputStream) : null; } private  IoUtil(); static String readResourceFile(Class<?> c, String fileName); static void copy(InputStream in, File dest); static String readFile(File file); static List<String> readFiles(File directory, FileFilter filter); static String readStream(InputStream is); static InputStream getRequestInputStream(HttpServletRequest request); static String readRequestBody(HttpServletRequest request);  }
@Test public void testReadRequestBody() throws Exception { MockHttpServletRequest request = new MockHttpServletRequest(); request.setContent(compress("test".getBytes(StandardCharsets.UTF_8))); request.addHeader("Content-Encoding", "gzip"); assertThat(IoUtil.readRequestBody(request)).isEqualTo("test"); }