public void doFilter
(HttpServletRequest request, HttpServletResponse response, HttpSession session, FilterChain chain)
throws ServletException, IOException
{
if (acceptsGzip(request)) {
GzipHttpServletResponse gzipResponse = new GzipHttpServletResponse(response, threshold, mimetypes);
chain.doFilter(request, gzipResponse);
gzipResponse.close(); // Mandatory for the case the threshold limit hasn't been reached.
}
else {
chain.doFilter(request, response);
}
}