wro4j-core/src/main/java/ro/isdc/wro/http/support/AbstractProcessorsFilter.java
public void doFilter(final ServletRequest req, final ServletResponse res, final FilterChain chain)
      throws IOException, ServletException {
    final HttpServletRequest request = (HttpServletRequest) req;
    final HttpServletResponse response = (HttpServletResponse) res;
    try {
      // add request, response & servletContext to thread local
      Context.set(Context.webContext(request, response, filterConfig));
      final ByteArrayOutputStream os = new ByteArrayOutputStream();
      final HttpServletResponse wrappedResponse = new RedirectedStreamServletResponseWrapper(os, response);
      chain.doFilter(request, wrappedResponse);
      final Reader reader = new StringReader(new String(os.toByteArray(), Context.get().getConfig().getEncoding()));

      final StringWriter writer = new StringWriter();
      final String requestUri = request.getRequestURI().replaceFirst(request.getContextPath(), "");
      doProcess(requestUri, reader, writer);
      // it is important to update the contentLength to new value, otherwise the transfer can be closed without all
      // bytes being read. Some browsers (chrome) complains with the following message: ERR_CONNECTION_CLOSED
      final int contentLength = writer.getBuffer().length();
      response.setContentLength(contentLength);
      // Content length can be 0 when the 30x (not modified) status code is returned.
      if (contentLength > 0) {
        IOUtils.write(writer.toString(), response.getOutputStream());
      }
    } catch (final RuntimeException e) {
      onRuntimeException(e, response, chain);
    } finally {
      Context.unset();
    }
  }
public void doFilter(final ServletRequest req, final ServletResponse res, final FilterChain chain)
      throws IOException, ServletException {
    final HttpServletRequest request = (HttpServletRequest) req;
    final HttpServletResponse response = (HttpServletResponse) res;
    try {
      // add request, response & servletContext to thread local
      Context.set(Context.webContext(request, response, filterConfig));
      final ByteArrayOutputStream os = new ByteArrayOutputStream();
      final HttpServletResponse wrappedResponse = new RedirectedStreamServletResponseWrapper(os, response);
      chain.doFilter(request, wrappedResponse);
      final Reader reader = new StringReader(new String(os.toByteArray(), Context.get().getConfig().getEncoding()));

      final StringWriter writer = new StringWriter();
      final String requestUri = request.getRequestURI().replaceFirst(request.getContextPath(), "");
      doProcess(requestUri, reader, writer);
      // it is important to update the contentLength to new value, otherwise the transfer can be closed without all
      // bytes being read. Some browsers (chrome) complains with the following message: ERR_CONNECTION_CLOSED
      final int contentLength = writer.getBuffer().length();
      response.setContentLength(contentLength);
      // Content length can be 0 when the 30x (not modified) status code is returned.
      if (contentLength > 0) {
        IOUtils.write(writer.toString(), response.getOutputStream());
      }
    } catch (final RuntimeException e) {
      onRuntimeException(e, response, chain);
    } finally {
      Context.unset();
    }
  }
public void doFilter ( final ServletRequest req , final ServletResponse res , final FilterChain chain ) throws IOException , ServletException { final HttpServletRequest request = ( HttpServletRequest ) req ; final HttpServletResponse response = ( HttpServletResponse ) res ; try { // add request, response & servletContext to thread local Context . set ( Context . webContext ( request , response , filterConfig ) ) ; final ByteArrayOutputStream os = new ByteArrayOutputStream ( ) ; final HttpServletResponse wrappedResponse = new RedirectedStreamServletResponseWrapper ( os , response ) ; chain . doFilter ( request , wrappedResponse ) ; final Reader reader = new StringReader ( new String ( os . toByteArray ( ) , Context . get ( ) . getConfig ( ) . getEncoding ( ) ) ) ; final StringWriter writer = new StringWriter ( ) ; final String requestUri = request . getRequestURI ( ) . replaceFirst ( request . getContextPath ( ) , "" ) ; doProcess ( requestUri , reader , writer ) ; // it is important to update the contentLength to new value, otherwise the transfer can be closed without all // bytes being read. Some browsers (chrome) complains with the following message: ERR_CONNECTION_CLOSED final int contentLength = writer . getBuffer ( ) . length ( ) ; response . setContentLength ( contentLength ) ; // Content length can be 0 when the 30x (not modified) status code is returned. if ( contentLength > 0 ) { IOUtils . write ( writer . toString ( ) , response . getOutputStream ( ) ) ; } } catch ( final RuntimeException e ) { onRuntimeException ( e , response , chain ) ; } finally { Context . unset ( ) ; } }
{@inheritDoc}
{