You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by Borut Bolčina <bo...@gmail.com> on 2011/09/12 15:14:31 UTC

Should T5 honor Accept-Encoding: gzip

Hi,

at the moment the only way to configure T5 response compression is via
tapestry.gzip-compression-enabled.

Should the configuration extend to support checking Accept-Encoding request
header?

-borut

Re: Should T5 honor Accept-Encoding: gzip

Posted by Borut Bolčina <bo...@gmail.com>.
Thanks,

I looked into sources now and I see how it works now. I was under assumption
that production mode also controls the compressing, well it is not.

I was experimenting a bit with headers and also by looking at the source
code of the isGZipSupported() method I can see that some rare cases are not
supported - like when client sends

Accept-Encoding: compress;q=0.5, gzip;q=1.0
or
Accept-Encoding: gzip;q=1.0

but I guess there are no clients like that (haven't checked the browsers).

-borut

2011/9/12 Steve Eynon <st...@alienfactory.co.uk>

> From GZipFilter implements HttpServletRequestFilter {
>
> private final ResponseCompressionAnalyzer analyzer;
>
> public boolean service(HttpServletRequest request, HttpServletResponse
> response, HttpServletRequestHandler handler)
>                throws IOException
> {
>        HttpServletResponse newResponse = analyzer.isGZipSupported()
>                                                                          ?
> new GZIPEnabledResponse(response, request, cutover, analyzer)
>                                                                          :
> response;
>
>        return handler.service(request, newResponse);
> }
> }
>
> with ResponseCompressionAnalyzer being
>
> public boolean isGZipSupported()
> {
>        if (!gzipCompressionEnabled)
>                return false;
>
>        String supportedEncodings = request.getHeader("Accept-Encoding");
>
>        if (supportedEncodings == null)
>                return false;
>
>        for (String encoding :
> TapestryInternalUtils.splitAtCommas(supportedEncodings))
>        {
>                if (encoding.equalsIgnoreCase("gzip"))
>                        return true;
>        }
>
>        return false;
> }
>
> I've read the entire source so far but it's looking pretty conclusive.
>
> Steve.
>
>
> On 12 September 2011 21:36, Borut Bolčina <bo...@gmail.com> wrote:
> > So, the header takes precedence over production mode setting and the
> > tapestry.gzip-compression-enabled?
> >
> > Is this really the case?
> >
> > -borut
> >
> > 2011/9/12 Steve Eynon <st...@alienfactory.co.uk>
> >
> >>
> >>
> http://tapestry.apache.org/current/apidocs/org/apache/tapestry5/services/ResponseCompressionAnalyzer.html
> >>
> >> Looks like it has been doing since T5.1.
> >>
> >> Steve.
> >>
> >>
> >> On 12 September 2011 21:14, Borut Bolčina <bo...@gmail.com>
> wrote:
> >> > Hi,
> >> >
> >> > at the moment the only way to configure T5 response compression is via
> >> > tapestry.gzip-compression-enabled.
> >> >
> >> > Should the configuration extend to support checking Accept-Encoding
> >> request
> >> > header?
> >> >
> >> > -borut
> >> >
> >>
> >> ---------------------------------------------------------------------
> >> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> >> For additional commands, e-mail: users-help@tapestry.apache.org
> >>
> >>
> >
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
>
>

Re: Should T5 honor Accept-Encoding: gzip

Posted by Steve Eynon <st...@alienfactory.co.uk>.
>From GZipFilter implements HttpServletRequestFilter {

private final ResponseCompressionAnalyzer analyzer;

public boolean service(HttpServletRequest request, HttpServletResponse
response, HttpServletRequestHandler handler)
		throws IOException
{
	HttpServletResponse newResponse = analyzer.isGZipSupported()
									  ? new GZIPEnabledResponse(response, request, cutover, analyzer)
									  : response;

	return handler.service(request, newResponse);
}
}

with ResponseCompressionAnalyzer being

public boolean isGZipSupported()
{
	if (!gzipCompressionEnabled)
		return false;

	String supportedEncodings = request.getHeader("Accept-Encoding");

	if (supportedEncodings == null)
		return false;

	for (String encoding : TapestryInternalUtils.splitAtCommas(supportedEncodings))
	{
		if (encoding.equalsIgnoreCase("gzip"))
			return true;
	}

	return false;
}

I've read the entire source so far but it's looking pretty conclusive.

Steve.


On 12 September 2011 21:36, Borut Bolčina <bo...@gmail.com> wrote:
> So, the header takes precedence over production mode setting and the
> tapestry.gzip-compression-enabled?
>
> Is this really the case?
>
> -borut
>
> 2011/9/12 Steve Eynon <st...@alienfactory.co.uk>
>
>>
>> http://tapestry.apache.org/current/apidocs/org/apache/tapestry5/services/ResponseCompressionAnalyzer.html
>>
>> Looks like it has been doing since T5.1.
>>
>> Steve.
>>
>>
>> On 12 September 2011 21:14, Borut Bolčina <bo...@gmail.com> wrote:
>> > Hi,
>> >
>> > at the moment the only way to configure T5 response compression is via
>> > tapestry.gzip-compression-enabled.
>> >
>> > Should the configuration extend to support checking Accept-Encoding
>> request
>> > header?
>> >
>> > -borut
>> >
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
>> For additional commands, e-mail: users-help@tapestry.apache.org
>>
>>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org


Re: Should T5 honor Accept-Encoding: gzip

Posted by Borut Bolčina <bo...@gmail.com>.
So, the header takes precedence over production mode setting and the
tapestry.gzip-compression-enabled?

Is this really the case?

-borut

2011/9/12 Steve Eynon <st...@alienfactory.co.uk>

>
> http://tapestry.apache.org/current/apidocs/org/apache/tapestry5/services/ResponseCompressionAnalyzer.html
>
> Looks like it has been doing since T5.1.
>
> Steve.
>
>
> On 12 September 2011 21:14, Borut Bolčina <bo...@gmail.com> wrote:
> > Hi,
> >
> > at the moment the only way to configure T5 response compression is via
> > tapestry.gzip-compression-enabled.
> >
> > Should the configuration extend to support checking Accept-Encoding
> request
> > header?
> >
> > -borut
> >
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
>
>

Re: Should T5 honor Accept-Encoding: gzip

Posted by Steve Eynon <st...@alienfactory.co.uk>.
http://tapestry.apache.org/current/apidocs/org/apache/tapestry5/services/ResponseCompressionAnalyzer.html

Looks like it has been doing since T5.1.

Steve.


On 12 September 2011 21:14, Borut Bolčina <bo...@gmail.com> wrote:
> Hi,
>
> at the moment the only way to configure T5 response compression is via
> tapestry.gzip-compression-enabled.
>
> Should the configuration extend to support checking Accept-Encoding request
> header?
>
> -borut
>

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org