code: @Override
      public void doFilter(ServletRequest request, ServletResponse response,
                           FilterChain chain) throws IOException, ServletException {
  
          ServletRequest req = getRequest(request);
  
          ServletResponse resp = getResponse(request, response);
  
          request.setAttribute(PROCESSED_ATTR, Boolean.TRUE);
  
          chain.doFilter(req, resp);
  
          if (resp instanceof CompressedHttpServletResponseWrapper) {
  
              CompressedHttpServletResponseWrapper compressedResponseWrapper = (CompressedHttpServletResponseWrapper) resp;
  
              try {
  
                  compressedResponseWrapper.close();  //so that stream is finished and closed.
  
              } catch (IOException ex) {
  
                  LOGGER.error("Response was already closed: ", ex.toString());
  
              }
  
              if (compressedResponseWrapper.isCompressed()) {
  
                  req.setAttribute(COMPRESSED_ATTR, Boolean.TRUE);
  
              }
  
          }
  
      }
docs: /* (non-Javadoc)
  @see javax.servlet.Filter#doFilter(javax.servlet.ServletRequest, javax.servlet.ServletResponse, javax.servlet.FilterChain)