[Helma-user] Suggestion on how to GZIP a response?
Kris Leite
kleite at imcsoftware.com
Thu Aug 16 18:06:55 CEST 2007
Hi Maks,
Thanks for the suggestion. The amount of code looks small enough but I
believe there are several exceptions that will cause it to be a more
complex. I just tried to look at Jetty 6 code for gzipfilter.java, it
looks a lot more code that it might be worth.
Thanks for the offer, but for right now I will pass. I was hoping a
simple configuration option was all that was needed.
Thanks,
Kris
Maksim Lin for technical support mailling lists wrote:
> 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: helma-user-bounces at helma.org
>> [mailto:helma-user-bounces at helma.org] 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
>>> Helma-user at helma.org
>>> http://helma.org/mailman/listinfo/helma-user
>>>
>>>
>>>
>> _______________________________________________
>> Helma-user mailing list
>> Helma-user at helma.org
>> http://helma.org/mailman/listinfo/helma-user
>>
>>
>>
>>
> _______________________________________________
> Helma-user mailing list
> Helma-user at helma.org
> http://helma.org/mailman/listinfo/helma-user
>
>
More information about the Helma-user
mailing list