//# 0 errors, 32 messages
//#
/*
    //#gzipfilter.java:1:1: class: net.sourceforge.pebble.web.filter.GZIPFilter
    //#gzipfilter.java:1:1: method: net.sourceforge.pebble.web.filter.GZIPFilter.net.sourceforge.pebble.web.filter.GZIPFilter__static_init
 * Copyright (c) 2003-2006, Simon Brown
 * All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions are met:
 *
 *   - Redistributions of source code must retain the above copyright
 *     notice, this list of conditions and the following disclaimer.
 *
 *   - Redistributions in binary form must reproduce the above copyright
 *     notice, this list of conditions and the following disclaimer in
 *     the documentation and/or other materials provided with the
 *     distribution.
 *
 *   - Neither the name of Pebble nor the names of its contributors may
 *     be used to endorse or promote products derived from this software
 *     without specific prior written permission.
 *
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
 * POSSIBILITY OF SUCH DAMAGE.
 */
package net.sourceforge.pebble.web.filter;

import javax.servlet.*;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

public class GZIPFilter implements Filter {
    //#gzipfilter.java:39: method: void net.sourceforge.pebble.web.filter.GZIPFilter.net.sourceforge.pebble.web.filter.GZIPFilter()
    //#gzipfilter.java:39: end of method: void net.sourceforge.pebble.web.filter.GZIPFilter.net.sourceforge.pebble.web.filter.GZIPFilter()

  public void doFilter(ServletRequest req, ServletResponse res,
                       FilterChain chain) throws IOException, ServletException {

      HttpServletRequest request = (HttpServletRequest) req;
    //#gzipfilter.java:44: method: void net.sourceforge.pebble.web.filter.GZIPFilter.doFilter(ServletRequest, ServletResponse, FilterChain)
    //#input(void doFilter(ServletRequest, ServletResponse, FilterChain)): chain
    //#input(void doFilter(ServletRequest, ServletResponse, FilterChain)): net/sourceforge/pebble/web/filter/GZIPResponseWrapper.__Descendant_Table[net/sourceforge/pebble/web/filter/GZIPResponseWrapper]
    //#input(void doFilter(ServletRequest, ServletResponse, FilterChain)): net/sourceforge/pebble/web/filter/GZIPResponseWrapper.__Dispatch_Table.finishResponse()V
    //#input(void doFilter(ServletRequest, ServletResponse, FilterChain)): req
    //#input(void doFilter(ServletRequest, ServletResponse, FilterChain)): res
    //#pre[1] (void doFilter(ServletRequest, ServletResponse, FilterChain)): chain != null
    //#pre[2] (void doFilter(ServletRequest, ServletResponse, FilterChain)): req != null
    //#unanalyzed(void doFilter(ServletRequest, ServletResponse, FilterChain)): Effects-of-calling:javax.servlet.http.HttpServletResponseWrapper
    //#unanalyzed(void doFilter(ServletRequest, ServletResponse, FilterChain)): Effects-of-calling:java.io.PrintWriter:close
    //#unanalyzed(void doFilter(ServletRequest, ServletResponse, FilterChain)): Effects-of-calling:javax.servlet.ServletOutputStream:close
    //#test_vector(void doFilter(ServletRequest, ServletResponse, FilterChain)): java.lang.String:indexOf(...)@48: {-1}, {-2_147_483_648..-2, 0..4_294_967_295}
    //#test_vector(void doFilter(ServletRequest, ServletResponse, FilterChain)): javax.servlet.http.HttpServletRequest:getHeader(...)@47: Addr_Set{null}, Inverse{null}
      HttpServletResponse response = (HttpServletResponse) res;

      String ae = request.getHeader("Accept-Encoding");
      if (ae != null && ae.indexOf("gzip") != -1) {
        GZIPResponseWrapper wrappedResponse = new GZIPResponseWrapper(response);
        chain.doFilter(req, wrappedResponse);
        wrappedResponse.finishResponse();
      } else {
        chain.doFilter(req, res);
      }
  }
    //#gzipfilter.java:55: end of method: void net.sourceforge.pebble.web.filter.GZIPFilter.doFilter(ServletRequest, ServletResponse, FilterChain)

  public void init(FilterConfig filterConfig) {
  }
    //#gzipfilter.java:58: method: void net.sourceforge.pebble.web.filter.GZIPFilter.init(FilterConfig)
    //#gzipfilter.java:58: end of method: void net.sourceforge.pebble.web.filter.GZIPFilter.init(FilterConfig)

  public void destroy() {
  }
    //#gzipfilter.java:61: method: void net.sourceforge.pebble.web.filter.GZIPFilter.destroy()
    //#gzipfilter.java:61: end of method: void net.sourceforge.pebble.web.filter.GZIPFilter.destroy()

}
    //#output(net.sourceforge.pebble.web.filter.GZIPFilter__static_init): __Descendant_Table[net/sourceforge/pebble/web/filter/GZIPFilter]
    //#output(net.sourceforge.pebble.web.filter.GZIPFilter__static_init): __Dispatch_Table.destroy()V
    //#output(net.sourceforge.pebble.web.filter.GZIPFilter__static_init): __Dispatch_Table.doFilter(Ljavax/servlet/ServletRequest;Ljavax/servlet/ServletResponse;Ljavax/servlet/FilterChain;)V
    //#output(net.sourceforge.pebble.web.filter.GZIPFilter__static_init): __Dispatch_Table.init(Ljavax/servlet/FilterConfig;)V
    //#post(net.sourceforge.pebble.web.filter.GZIPFilter__static_init): __Descendant_Table[net/sourceforge/pebble/web/filter/GZIPFilter] == &__Dispatch_Table
    //#post(net.sourceforge.pebble.web.filter.GZIPFilter__static_init): __Dispatch_Table.destroy()V == &destroy
    //#post(net.sourceforge.pebble.web.filter.GZIPFilter__static_init): __Dispatch_Table.doFilter(Ljavax/servlet/ServletRequest;Ljavax/servlet/ServletResponse;Ljavax/servlet/FilterChain;)V == &doFilter
    //#post(net.sourceforge.pebble.web.filter.GZIPFilter__static_init): __Dispatch_Table.init(Ljavax/servlet/FilterConfig;)V == &init
    //#gzipfilter.java:: end of method: net.sourceforge.pebble.web.filter.GZIPFilter.net.sourceforge.pebble.web.filter.GZIPFilter__static_init
    //#gzipfilter.java:: end of class: net.sourceforge.pebble.web.filter.GZIPFilter
