I have implemented a Filter, in which I want to read the content of request first for some checks and then I would like to go on.
But the problem is, that in the fol
ContentCachingRequestWrapper doesnt work that way and has some limitations. Only POST request and content type should be application/x-www-form-urlencoded as far as I remember. If this fits for you, here's what you should do:
final HttpServletRequest req = (HttpServletRequest) request;
HttpServletRequest servletRequest = new ContentCachingRequestWrapper(req);
servletRequest.getParameterMap(); // needed for caching!!
String read = ByteSource.wrap(servletRequest.getContentAsByteArray())
.asCharSource(StandardCharsets.UTF_8).read(); // Please note that we're not touching input stream!!
Hope this helps.