Return-Path: Delivered-To: apmail-cocoon-users-archive@www.apache.org Received: (qmail 38706 invoked from network); 16 Dec 2003 08:03:25 -0000 Received: from daedalus.apache.org (HELO mail.apache.org) (208.185.179.12) by minotaur-2.apache.org with SMTP; 16 Dec 2003 08:03:25 -0000 Received: (qmail 63926 invoked by uid 500); 16 Dec 2003 08:02:53 -0000 Delivered-To: apmail-cocoon-users-archive@cocoon.apache.org Received: (qmail 63902 invoked by uid 500); 16 Dec 2003 08:02:53 -0000 Mailing-List: contact users-help@cocoon.apache.org; run by ezmlm Precedence: bulk list-help: list-unsubscribe: list-post: Reply-To: users@cocoon.apache.org Delivered-To: mailing list users@cocoon.apache.org Received: (qmail 63889 invoked from network); 16 Dec 2003 08:02:53 -0000 Received: from unknown (HELO ivmail1.fcc.es) (195.235.176.9) by daedalus.apache.org with SMTP; 16 Dec 2003 08:02:53 -0000 Received: from fcccorreo1.sg.gr.fcc.es ([10.1.1.190]) by ivmail1 with InterScan Messaging Security Suite; Tue, 16 Dec 2003 09:04:19 +0100 Received: from blcorreo1.sg.gr.fcc.es ([10.17.18.232]) by fcccorreo1.sg.gr.fcc.es with Microsoft SMTPSVC(5.0.2195.6713); Tue, 16 Dec 2003 09:03:03 +0100 content-class: urn:content-classes:message Subject: RE: gzip compression Date: Tue, 16 Dec 2003 09:03:03 +0100 Message-ID: MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable X-MS-Has-Attach: X-MS-TNEF-Correlator: Thread-Topic: gzip compression X-MimeOLE: Produced By Microsoft Exchange V6.0.6375.0 Thread-Index: AcPDNEHvsVV2ZVVPR0G7Tlyd7tzQDwAdrQag From: "Carmona Perez, David" To: , X-OriginalArrivalTime: 16 Dec 2003 08:03:03.0834 (UTC) FILETIME=[080C17A0:01C3C3AB] X-Spam-Rating: daedalus.apache.org 1.6.2 0/1000/N X-Spam-Rating: minotaur-2.apache.org 1.6.2 0/1000/N Thanks, the latest versions of Tomcat 4.1 already support it. -------- David -----Mensaje original----- De: Nicolas Toper [mailto:ntoper@jouve.fr] Enviado el: lunes, 15 de diciembre de 2003 18:56 Para: users@cocoon.apache.org Asunto: Re: gzip compression Apache could do that automatically... Otherwise, I'd use Tomcat and a filter servlet to do it: you could find = some all ready to be used on the Web... Le Lundi 15 D=E9cembre 2003 18:46, Carmona Perez, David a =E9crit : > Hi all, > > Does someone how can I make some action that activates compressing = output > data using GZip? Gzip compression is an HTTP 1.1 standard feature. > > Ideally it would be great if it could be like an action, so that it's = easy > to activate it on or off. I have tried this code: > > import java.io.IOException; > import java.io.OutputStream; > import java.util.Map; > import java.util.zip.GZIPOutputStream; > > import javax.servlet.ServletOutputStream; > import javax.servlet.http.HttpServletResponse; > > import org.apache.avalon.framework.parameters.Parameters; > import org.apache.cocoon.acting.AbstractAction; > import org.apache.cocoon.environment.ObjectModelHelper; > import org.apache.cocoon.environment.Redirector; > import org.apache.cocoon.environment.Request; > import org.apache.cocoon.environment.SourceResolver; > import org.apache.cocoon.environment.http.HttpEnvironment; > import org.apache.cocoon.environment.http.HttpResponse; > > public class CompressAction extends AbstractAction { > class StreamGzip extends ServletOutputStream { > public StreamGzip(OutputStream out) throws IOException { > gzip =3D new GZIPOutputStream(out); > } > /** @see java.io.OutputStream#write(int) */ > public void write(int b) throws IOException { > gzip.write(b); > } > /** @see java.io.OutputStream#close() */ > public void close() throws IOException { > gzip.close(); > } > /** @see java.io.OutputStream#flush() */ > public void flush() throws IOException { > gzip.flush(); > } > private GZIPOutputStream gzip; > } > class GzipResponse extends HttpResponse { > GzipResponse(HttpServletResponse resp) throws = IOException { > super(resp); > os =3D new StreamGzip(resp.getOutputStream()); > } > public ServletOutputStream getOutputStream() throws = IOException { > return os; > } > StreamGzip os; > } > public Map act(Redirector redirector, SourceResolver resolver, = Map > objectModel, String source, Parameters parameters) throws Exception { > Request pet =3D ObjectModelHelper.getRequest(objectModel); > String accept =3D pet.getHeader("Accept-Encoding"); > if (accept !=3D null && accept.indexOf("gzip") >=3D 0) { > GzipResponse resp =3D new > = GzipResponse((HttpServletResponse)objectModel.get(HttpEnvironment.HTTP_RE= SP >ONSE_OBJECT)); resp.setHeader("Content-Encoding", "gzip"); > = objectModel.put(ObjectModelHelper.RESPONSE_OBJECT, resp); > return EMPTY_MAP; > } > return null; > } > } > > But it doesn't work, because the HttpEnvironment holds also holds a > reference to the outputstream. Which is the cleanest way to perform = this? > Any suggestion will be greatly appreciated. > > > -------- > David > > > --------------------------------------------------------------------- > To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org > For additional commands, e-mail: users-help@cocoon.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org For additional commands, e-mail: users-help@cocoon.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org For additional commands, e-mail: users-help@cocoon.apache.org