I am trying to capture the request body string using entity stream in both request filter and response filter. But when I try to fetch request body string entity stream in the response filter, I get the entity stream closed exception. Is there a way where I can use the entity stream in the response filter. Basically, I want to get the request string in both request and response filter. Any help is appreciated
@Overridepublic void filter(ContainerRequestContext requestContext) { InputStream entityStream = requestContext.getEntityStream(); byte[] entityBytes = entityStream.readAllBytes(); String requestBody = new String(entityBytes, StandardCharsets.UTF_8);}@Overridepublic void filter(ContainerRequestContext requestContext,ContainerResponseContext responseContext) { InputStream entityStream = requestContext.getEntityStream(); //This throws entity close exception. I need request in response filter}