Re: Suggestion on how to GZIP a response?

"Maksim Lin for technical support mailling lists" <[email protected]> Thu, 16 Aug 2007 09:40:39 +1000
Newsgroups gmane.comp.java.helma.general
Message-ID <[email protected]>
Hi Kris,

This article
(http://www.onjava.com/pub/a/onjava/2003/11/19/filters.html)
describes the implementation of a servlet filter to do gzip responses.

>From a *very quick* look at the code it looks fairly straight forward. 

Looks like you need code to check if the client will accept gzip:

HttpServletRequest request = (HttpServletRequest) req;
String ae = request.getHeader("accept-encoding");
if (ae != null && ae.indexOf("gzip") != -1) { 
...

and then when you write your response:

HttpServletResponse response =
          (HttpServletResponse) res;
this.output = response.getOutputStream();
baos = new ByteArrayOutputStream();
gzipstream = new GZIPOutputStream(baos);
gzipstream.write((byte)b);
...

The above is in Java rather then js (in helma for instance you would do
just do req.getHeader() to get a HTTP header, etc), but hopefully it
gives the idea.
I use apache as a front-end too, so I don't have any immediate need for
this, but I could have a quick go at writing up a little module to do
this if there is interest.
Actually I think this functionality would actually be better of inside
helma core code and then just activiated for each app with a setting in
app.properties, espeically given the small size of Java code needed to
implement it.

Maks.


> -----Original Message-----
> From: [email protected] 
> [mailto:[email protected]] On Behalf Of Kris Leite
> Sent: Thursday, 16 August 2007 06:09
> To: Helma User Mailing List
> Subject: Re: [Helma-user] Suggestion on how to GZIP a response?
> 
> Thanks for the suggestion but no, I am not using a proxy.
> 
> Thanks,
> Kris
> 
> Joshua Paine wrote:
> > Kris Leite wrote:
> >  
> >> I was wondering if anybody has a suggestion on how to 
> configure Helma 
> >> to GZIP the responses?
> >>    
> >
> > If you're proxying through apache, it's as easy as enabling 
> > mod_deflate in your server and adding this to your virtual host:
> >
> > SetOutputFilter DEFLATE
> >
> > I have no idea otherwise, though.
> > _______________________________________________
> > Helma-user mailing list
> > [email protected]
> > http://helma.org/mailman/listinfo/helma-user
> >
> >  
> _______________________________________________
> Helma-user mailing list
> [email protected]
> http://helma.org/mailman/listinfo/helma-user
> 
> 
>