Package org.apache.roller.ui.core.util

Examples of org.apache.roller.ui.core.util.ByteArrayResponseWrapper


        } else {
            // Tell browser we are sending it gzipped data.
            res.setHeader("Content-Encoding", "gzip");
           
            // Invoke resource, accumulating output in the wrapper.
            ByteArrayResponseWrapper responseWrapper =
                    new ByteArrayResponseWrapper(response);
           
            chain.doFilter(req, responseWrapper);
           
            ByteArrayOutputStream outputStream = responseWrapper.getByteArrayOutputStream();
           
            // Get character array representing output.
            mLogger.debug("Pre-zip size:" + outputStream.size());
           
            // Make a writer that compresses data and puts
            // it into a byte array.
            ByteArrayOutputStream byteStream = new ByteArrayOutputStream();
            GZIPOutputStream zipOut = new GZIPOutputStream(byteStream);
           
            // Compress original output and put it into byte array.
            zipOut.write(responseWrapper.getByteArrayOutputStream().toByteArray());
           
            // Gzip streams must be explicitly closed.
            zipOut.close();
           
            mLogger.debug("Gzip size:" + byteStream.size());
           
            // Update the Content-Length header.
            res.setContentLength(byteStream.size());
           
            ByteArrayOutputStreamWrapper newOut =
                    (ByteArrayOutputStreamWrapper) responseWrapper.getOutputStream();
            newOut.clear();
            newOut.setFinallized();
           
            /* now force close of OutputStream */
            newOut.write(byteStream.toByteArray());
View Full Code Here

TOP

Related Classes of org.apache.roller.ui.core.util.ByteArrayResponseWrapper

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.