`
收藏列表
标题 标签 来源
Gzip过滤 gzip
/*jadclipse*/// Decompiled by Jad v1.5.8g. Copyright 2001 Pavel Kouznetsov.
// Jad home page: http://www.kpdus.com/jad.html
// Decompiler options: packimports(3) radix(10) lradix(10) 
// Source File Name:   EAPGZipFilter.java

package com.neusoft.ermsuite.platform.unieap.util;

import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import java.util.zip.GZIPOutputStream;
import javax.servlet.*;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

// Referenced classes of package com.neusoft.ermsuite.platform.unieap.util:
//            Wrapper, EAPAppContext

public class EAPGZipFilter
    implements Filter
{

    public EAPGZipFilter()
    {
    }

    public void destroy()
    {
    }

    public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain)
        throws IOException, ServletException
    {
        String _eapsyspath = ((HttpServletRequest)request).getServletPath();
        if(isNoCompPress(_eapsyspath))
        {
            chain.doFilter(request, response);
            return;
        } else
        {
            HttpServletResponse resp = (HttpServletResponse)response;
            Wrapper wrapper = new Wrapper(resp);
            chain.doFilter(request, wrapper);
            byte gzipData[] = gzip(wrapper.getResponseData());
            resp.addHeader("Content-Encoding", "gzip");
            resp.setContentLength(gzipData.length);
            ServletOutputStream output = response.getOutputStream();
            output.write(gzipData);
            output.flush();
            return;
        }
    }

    private byte[] gzip(byte data[])
    {
        ByteArrayOutputStream byteOutput;
        GZIPOutputStream output;
        byteOutput = new ByteArrayOutputStream(10240);
        output = null;
        try
        {
            output = new GZIPOutputStream(byteOutput);
            output.write(data);
            break MISSING_BLOCK_LABEL_71;
        }
        catch(IOException e)
        {
            e.printStackTrace();
        }
        if(output != null)
            try
            {
                output.close();
            }
            catch(IOException ioexception) { }
        break MISSING_BLOCK_LABEL_84;
        Exception exception;
        exception;
        if(output != null)
            try
            {
                output.close();
            }
            catch(IOException ioexception1) { }
        throw exception;
        if(output != null)
            try
            {
                output.close();
            }
            catch(IOException ioexception2) { }
        return byteOutput.toByteArray();
    }

    public void init(FilterConfig fConfig)
        throws ServletException
    {   //noCompressPages=Report-DocPrintAction;Buyplan;textinfoList
        String noCompressPages = EAPAppContext.getInstance().getProperty("noCompressPages");
        String str[] = noCompressPages.split(";");
        try
        {
            for(int i = 0; i < str.length; i++)
                pages.add(str[i]);

        }
        catch(Exception e)
        {
            e.printStackTrace();
        }
    }

    public boolean isNoCompPress(String url)
    {
        boolean flag = false;
        String str = null;
        for(int i = 0; i < pages.size(); i++)
        {
            str = (String)pages.get(i);
            if(url.indexOf(str) == -1)
                continue;
            flag = true;
            break;
        }

        return flag;
    }

    private static List pages = new ArrayList();

}
Global site tag (gtag.js) - Google Analytics