亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? compressionresponsestream.java

?? java servlet著名論壇源代碼
?? JAVA
字號:
/*
 * CompressionResponseStream.java
 * $Header: /cvsroot/mvnforum/myvietnam/src/net/myvietnam/mvncore/servlet/filter/CompressionResponseStream.java,v 1.2 2004/03/16 12:58:46 minhnn Exp $
 * $Revision: 1.2 $
 * $Date: 2004/03/16 12:58:46 $
 *
 * ====================================================================
 *
 * The Apache Software License, Version 1.1
 *
 * Copyright (c) 1999 The Apache Software Foundation.  All rights
 * reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions
 * are met:
 *
 * 1. Redistributions of source code must retain the above copyright
 *    notice, this list of conditions and the following disclaimer.
 *
 * 2. 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.
 *
 * 3. The end-user documentation included with the redistribution, if
 *    any, must include the following acknowlegement:
 *       "This product includes software developed by the
 *        Apache Software Foundation (http://www.apache.org/)."
 *    Alternately, this acknowlegement may appear in the software itself,
 *    if and wherever such third-party acknowlegements normally appear.
 *
 * 4. The names "The Jakarta Project", "Tomcat", and "Apache Software
 *    Foundation" must not be used to endorse or promote products derived
 *    from this software without prior written permission. For written
 *    permission, please contact apache@apache.org.
 *
 * 5. Products derived from this software may not be called "Apache"
 *    nor may "Apache" appear in their names without prior written
 *    permission of the Apache Group.
 *
 * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED 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 APACHE SOFTWARE FOUNDATION OR
 * ITS 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.
 * ====================================================================
 *
 * This software consists of voluntary contributions made by many
 * individuals on behalf of the Apache Software Foundation.  For more
 * information on the Apache Software Foundation, please see
 * <http://www.apache.org/>.
 *
 * [Additional notices, if required by prior licensing conditions]
 *
 */

package net.myvietnam.mvncore.servlet.filter;

import java.io.IOException;
import java.util.zip.GZIPOutputStream;
import javax.servlet.ServletOutputStream;
import javax.servlet.http.HttpServletResponse;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;


/**
 * Implementation of <b>ServletOutputStream</b> that works with
 * the CompressionServletResponseWrapper implementation.
 *
 * @author Amy Roh
 * @author Dmitri Valdin
 * @version $Revision: 1.2 $, $Date: 2004/03/16 12:58:46 $
 */

public class CompressionResponseStream extends ServletOutputStream {

    //minhnn : I remove the log because log4j does not support TRACE level
    private static Log log = LogFactory.getLog(CompressionResponseStream.class);

    // ----------------------------------------------------------- Constructors


    /**
     * Construct a servlet output stream associated with the specified Response.
     *
     * @param response The associated response
     */
    public CompressionResponseStream(HttpServletResponse response) throws IOException{

        super();
        closed = false;
        this.response = response;
        this.output = response.getOutputStream();

    }


    // ----------------------------------------------------- Instance Variables


    /**
     * The threshold number which decides to compress or not.
     * Users can configure in web.xml to set it to fit their needs.
     */
    protected int compressionThreshold = 0;

    /**
     * Debug level
     */
//    private int debug = 0;

    /**
     * The buffer through which all of our output bytes are passed.
     */
    protected byte[] buffer = null;

    /**
     * The number of data bytes currently in the buffer.
     */
    protected int bufferCount = 0;

    /**
     * The underlying gzip output stream to which we should write data.
     */
    protected GZIPOutputStream gzipstream = null;

    /**
     * Has this stream been closed?
     */
    protected boolean closed = false;

    /**
     * The content length past which we will not write, or -1 if there is
     * no defined content length.
     */
    protected int length = -1;

    /**
     * The response with which this servlet output stream is associated.
     */
    protected HttpServletResponse response = null;

    /**
     * The underlying servket output stream to which we should write data.
     */
    protected ServletOutputStream output = null;


    // --------------------------------------------------------- Public Methods

    /**
     * Set debug level
     */
//    public void setDebugLevel(int debug) {
//        this.debug = debug;
//    }


    /**
     * Set the compressionThreshold number and create buffer for this size
     */
    protected void setBuffer(int threshold) {
        compressionThreshold = threshold;
        buffer = new byte[compressionThreshold];
        //log.trace("buffer is set to " + compressionThreshold);
    }

    /**
     * Close this output stream, causing any buffered data to be flushed and
     * any further output data to throw an IOException.
     */
    public void close() throws IOException {

        //log.trace("close() @ CompressionResponseStream", new IOException("tracing"));
        if (closed) {
            //minhnn : instead of throw IOException, we should log waring or even
            // ignore it so that it does not throw exception when close many time
            throw new IOException("This output stream has already been closed");
            //log.warn("This output stream has already been closed");
        }

        if (gzipstream != null) {
            flushToGZip();
            gzipstream.close();
            gzipstream = null;
        } else {
            if (bufferCount > 0) {
                // minhnn comment
                /*
                if (debug > 2) {
                    System.out.print("output.write(");
                    System.out.write(buffer, 0, bufferCount);
                    System.out.println(")");
                }*/
                output.write(buffer, 0, bufferCount);
                bufferCount = 0;
            }
        }

        output.close();
        closed = true;

    }


    /**
     * Flush any buffered data for this output stream, which also causes the
     * response to be committed.
     */
    public void flush() throws IOException {

        //log.trace("flush() @ CompressionResponseStream");
        if (closed) {
            //throw new IOException("Cannot flush a closed output stream");
            log.warn("Cannot flush a closed output stream");
        }

        if (gzipstream != null) {
            gzipstream.flush();
        }

    }

    public void flushToGZip() throws IOException {

        //log.trace("flushToGZip() @ CompressionResponseStream");
        if (bufferCount > 0) {
            //log.trace("flushing out to GZipStream, bufferCount = " + bufferCount);
            writeToGZip(buffer, 0, bufferCount);
            bufferCount = 0;
        }

    }

    /**
     * Write the specified byte to our output stream.
     *
     * @param b The byte to be written
     *
     * @exception IOException if an input/output error occurs
     */
    public void write(int b) throws IOException {

        //log.trace("write " + b + " in CompressionResponseStream ");
        if (closed)
            throw new IOException("Cannot write to a closed output stream");

        if (bufferCount >= buffer.length) {
            flushToGZip();
        }

        buffer[bufferCount++] = (byte) b;

    }


    /**
     * Write <code>b.length</code> bytes from the specified byte array
     * to our output stream.
     *
     * @param b The byte array to be written
     *
     * @exception IOException if an input/output error occurs
     */
    public void write(byte b[]) throws IOException {

        write(b, 0, b.length);

    }


    /**
     * Write <code>len</code> bytes from the specified byte array, starting
     * at the specified offset, to our output stream.
     *
     * @param b The byte array containing the bytes to be written
     * @param off Zero-relative starting offset of the bytes to be written
     * @param len The number of bytes to be written
     *
     * @exception IOException if an input/output error occurs
     */
    public void write(byte b[], int off, int len) throws IOException {

        //log.trace("write, bufferCount = " + bufferCount + " len = " + len + " off = " + off);
        /* minhnn comment
        if (debug > 2) {
            System.out.print("write(");
            System.out.write(b, off, len);
            System.out.println(")");
        }*/

        if (closed)
            throw new IOException("Cannot write to a closed output stream");

        if (len == 0)
            return;

        // Can we write into buffer ?
        if (len <= (buffer.length - bufferCount)) {
            System.arraycopy(b, off, buffer, bufferCount, len);
            bufferCount += len;
            return;
        }

        // There is not enough space in buffer. Flush it ...
        flushToGZip();

        // ... and try again. Note, that bufferCount = 0 here !
        if (len <= (buffer.length - bufferCount)) {
            System.arraycopy(b, off, buffer, bufferCount, len);
            bufferCount += len;
            return;
        }

        // write direct to gzip
        writeToGZip(b, off, len);
    }

    public void writeToGZip(byte b[], int off, int len) throws IOException {

        //log.trace("writeToGZip, len = " + len);
        /* minhnn comment
        if (debug > 2) {
            System.out.print("writeToGZip(");
            System.out.write(b, off, len);
            System.out.println(")");
        }*/
        if (gzipstream == null) {
            //log.trace("new GZIPOutputStream");
            response.addHeader("Content-Encoding", "gzip");
            gzipstream = new GZIPOutputStream(output);
        }
        gzipstream.write(b, off, len);

    }


    // -------------------------------------------------------- Package Methods


    /**
     * Has this response stream been closed?
     */
    public boolean closed() {

        return (this.closed);

    }

}

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
亚洲高清中文字幕| 91麻豆swag| 久久久久久一二三区| 国产精品色哟哟网站| 日本午夜一本久久久综合| 成人高清视频免费观看| 精品久久免费看| 亚洲国产欧美在线人成| 成人午夜精品在线| 久久青草国产手机看片福利盒子 | 色哟哟一区二区在线观看| 欧美xfplay| 亚洲123区在线观看| 91美女福利视频| 国产欧美一区二区在线观看| 蜜臀久久久久久久| 欧美日韩一区二区三区视频| 亚洲欧美在线观看| 国产凹凸在线观看一区二区| 日韩欧美一卡二卡| 日韩精品欧美精品| 欧美系列在线观看| 亚洲午夜免费福利视频| 91色porny| 日韩毛片视频在线看| 国产成人亚洲综合a∨婷婷图片| 日韩一区二区免费在线观看| 五月天激情小说综合| 91精品办公室少妇高潮对白| 亚洲欧美一区二区久久| 99精品热视频| 日韩美女视频19| 色哟哟国产精品| 亚洲免费毛片网站| 在线视频国内一区二区| 亚洲一区二区三区四区中文字幕| 欧美综合亚洲图片综合区| 中文字幕综合网| 欧美亚洲禁片免费| 亚洲电影一级黄| 欧美丰满嫩嫩电影| 激情成人综合网| 久久久不卡网国产精品二区| 国产精品99精品久久免费| 中文幕一区二区三区久久蜜桃| 成人免费看视频| 亚洲色图清纯唯美| 91国产精品成人| 亚洲欧美区自拍先锋| 884aa四虎影成人精品一区| 日韩国产欧美三级| 一级做a爱片久久| 日韩欧美成人一区| 欧美精品xxxxbbbb| 国产精品久久久久久户外露出 | 欧美在线观看视频一区二区三区| 国产米奇在线777精品观看| 久久av资源网| 91在线视频播放地址| 欧美中文字幕亚洲一区二区va在线 | 久久九九久久九九| 成人美女视频在线看| 亚洲欧美日韩国产另类专区| 欧美日韩国产免费一区二区| 久久精品国产第一区二区三区| 国产欧美一区二区精品婷婷 | 久久综合视频网| 91免费国产视频网站| 亚洲国产乱码最新视频| 欧美成人video| 97超碰欧美中文字幕| 美腿丝袜在线亚洲一区| 亚洲图片另类小说| 日韩视频在线观看一区二区| 99久久婷婷国产综合精品| 日产国产欧美视频一区精品| 国产精品蜜臀在线观看| 91精品国产色综合久久ai换脸| 国产二区国产一区在线观看| 亚洲成av人综合在线观看| 欧美激情一区二区三区| 欧美一区二区三区四区五区 | 国产精品久久久久一区二区三区共| 欧美性一二三区| 成人免费av在线| 另类调教123区| 亚洲愉拍自拍另类高清精品| 欧美激情资源网| 欧美成人精品3d动漫h| 在线免费不卡电影| 成人激情黄色小说| 国产成人精品亚洲午夜麻豆| 日本sm残虐另类| 亚洲国产欧美一区二区三区丁香婷| 中文成人av在线| 久久免费国产精品| 日韩午夜精品电影| 777午夜精品免费视频| 欧美性xxxxx极品少妇| 成人免费毛片a| 国产不卡视频在线观看| 国产制服丝袜一区| 韩国欧美一区二区| 久久99日本精品| 美女在线视频一区| 日本欧美肥老太交大片| 香蕉成人伊视频在线观看| 亚洲精品中文字幕在线观看| 亚洲人成精品久久久久久| 日本一区二区视频在线| 久久久久久97三级| 国产亚洲一二三区| 国产日韩高清在线| 欧美激情综合在线| 欧美韩日一区二区三区四区| 欧美高清在线精品一区| 欧美经典三级视频一区二区三区| 国产欧美日韩在线| 国产精品视频九色porn| 亚洲欧洲av一区二区三区久久| 国产欧美在线观看一区| 国产精品久久久久久久久免费樱桃| 久久精品网站免费观看| 中文字幕免费观看一区| 亚洲欧美日韩在线| 亚洲一区在线观看免费观看电影高清| 亚洲一区免费视频| 亚洲国产一区视频| 天天综合天天综合色| 另类调教123区| 国产91对白在线观看九色| 91视视频在线直接观看在线看网页在线看| 成年人网站91| 91福利视频久久久久| 7777精品伊人久久久大香线蕉的| 日韩一区二区不卡| 久久久久国产精品人| 亚洲视频精选在线| 香蕉av福利精品导航| 国产麻豆视频精品| 一本久道久久综合中文字幕 | 欧美一区二区三区公司| 另类小说图片综合网| 国内精品伊人久久久久av影院| 国产精一品亚洲二区在线视频| 成人av网址在线| 色999日韩国产欧美一区二区| 亚洲1区2区3区4区| 欧美日韩国产在线播放网站| 亚洲免费观看高清完整版在线观看| 国产欧美日韩在线观看| 久久久午夜精品理论片中文字幕| 日本一区免费视频| 一个色妞综合视频在线观看| 日韩高清国产一区在线| 国产福利91精品一区二区三区| 在线精品视频免费观看| 精品电影一区二区三区| 亚洲精品v日韩精品| 蜜桃一区二区三区四区| 成人av电影免费观看| 欧美一卡二卡三卡四卡| 中文字幕巨乱亚洲| 日本在线不卡一区| 在线精品视频一区二区| 国产婷婷色一区二区三区| 亚洲成av人片一区二区梦乃| 国产高清在线精品| 欧美一级片在线看| 一区二区三区四区高清精品免费观看| 麻豆国产精品777777在线| 色av综合在线| 国产精品久久午夜夜伦鲁鲁| 强制捆绑调教一区二区| 欧美亚洲综合色| 国产精品久久久久影院亚瑟| 麻豆精品在线播放| 一道本成人在线| 国产精品三级av| 国产一区二区三区在线观看免费视频 | av综合在线播放| 国产午夜精品一区二区三区四区 | 国产1区2区3区精品美女| 日韩欧美中文字幕精品| 亚洲国产精品一区二区久久| 99久久综合国产精品| 欧美激情资源网| 国产91精品欧美| 国产午夜精品在线观看| 国产成人高清在线| 久久综合九色综合欧美亚洲| 日韩高清中文字幕一区| 亚洲欧洲综合另类在线| 欧美a级理论片| 欧美色图在线观看| 久久精品在这里| 福利电影一区二区三区| 欧美精品一区二区三区蜜桃视频| 亚洲综合男人的天堂| 成人黄色电影在线|