You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by Steve Appling <sa...@mindspring.com> on 2003/09/17 16:57:55 UTC

[PATCH] fix compression="on" option on coyote connector

Currently the option for compression="on" in the coyote connector is broken
(see bug 18073).  The solution presented in the patches attached to that bug
seemed overly complicated.  Here is an alternate patch that also fixes the
problem.

This patch changes 3 things:
1) Decreases the minimum compression size to 1k - this seemed to help with
my particular application.  There was a lot in the range of 1-2k.
2) Checks only that the content type starts with an entry in the
compressableMimeTypes list instead of checking equality.  This is the real
bug fix since the contentType also includes the character encoding
information.
3) Added application/x-javascript as a default compressable type.  Now it
allows all mime types starting with "text/", not just the three previously
specified.


Index: Http11Processor.java
===================================================================
RCS file:
/home/cvspublic/jakarta-tomcat-connectors/http11/src/java/org/apache/coyote/
http11/Http11Processor.java,v
retrieving revision 1.78
diff -r1.78 Http11Processor.java
273c273
<     protected int compressionMinSize = 2048;
---
>     protected int compressionMinSize = 1024;
291c291
<     protected String[] compressableMimeTypes = { "text/html", "text/xml",
"text/plain" };
---
>     protected String[] compressableMimeTypes = { "text/",
"application/x-javascript" };
462a463,478
>        /**
>      * General use method
>      *
>      * @param sArray the StringArray
>      * @param value string
>      */
>     private boolean startsWithStringArray(String sArray[], String value) {
>         if (value == null)
>            return false;
>         for (int i = 0; i < sArray.length; i++) {
>             if (value.startsWith(sArray[i])) {
>                 return true;
>             }
>         }
>         return false;
>     }
1216,1217c1232,1233
<             if (compressableMimeTypes != null)
<                 return (inStringArray(compressableMimeTypes,
response.getContentType()));
---
>             if (compressableMimeTypes != null)
>                return (startsWithStringArray(compressableMimeTypes,
response.getContentType()));


---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-dev-help@jakarta.apache.org


Re: [PATCH] fix compression="on" option on coyote connector

Posted by Remy Maucherat <re...@apache.org>.
Henri Gomez wrote:

> Steve Appling a écrit :
> 
>> Currently the option for compression="on" in the coyote connector is 
>> broken
>> (see bug 18073).  The solution presented in the patches attached to 
>> that bug
>> seemed overly complicated.  Here is an alternate patch that also fixes 
>> the
>> problem.
>>
>> This patch changes 3 things:
>> 1) Decreases the minimum compression size to 1k - this seemed to help 
>> with
>> my particular application.  There was a lot in the range of 1-2k.
> 
> Are you sure you want to compress content less than 2k ?
> 
> BTW, you could use compression property for your purpose.

Well, it's a default value. I'd say there's indeed not much point 
compressing resources which are too small.

>> 2) Checks only that the content type starts with an entry in the
>> compressableMimeTypes list instead of checking equality.  This is the 
>> real
>> bug fix since the contentType also includes the character encoding
>> information.
> 
> That's the way it's done on Apache HTTPD mod_deflate.

But how can it work without the startsWith ? The charset definitely 
messes up the test. Or we have to look for ";" in the charset String and 
use a region match.

>> 3) Added application/x-javascript as a default compressable type.  Now it
>> allows all mime types starting with "text/", not just the three 
>> previously
>> specified.
> 
> Nope there is problems with many browser which didn't support gzipped 
> javascript.

Sounds reasonable.

Remy



---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-dev-help@jakarta.apache.org


Re: [PATCH] fix compression="on" option on coyote connector

Posted by Remy Maucherat <re...@apache.org>.
Henri Gomez wrote:

> Steve Appling a écrit :
> 
>> Currently the option for compression="on" in the coyote connector is 
>> broken
>> (see bug 18073).  The solution presented in the patches attached to 
>> that bug
>> seemed overly complicated.  Here is an alternate patch that also fixes 
>> the
>> problem.
>>
>> This patch changes 3 things:
>> 1) Decreases the minimum compression size to 1k - this seemed to help 
>> with
>> my particular application.  There was a lot in the range of 1-2k.
> 
> Are you sure you want to compress content less than 2k ?
> 
> BTW, you could use compression property for your purpose.

Well, it's a default value. I'd say there's indeed not much point 
compressing resources which are too small.

>> 2) Checks only that the content type starts with an entry in the
>> compressableMimeTypes list instead of checking equality.  This is the 
>> real
>> bug fix since the contentType also includes the character encoding
>> information.
> 
> That's the way it's done on Apache HTTPD mod_deflate.

But how can it work without the startsWith ? The charset definitely 
messes up the test. Or we have to look for ";" in the charset String and 
use a region match.

>> 3) Added application/x-javascript as a default compressable type.  Now it
>> allows all mime types starting with "text/", not just the three 
>> previously
>> specified.
> 
> Nope there is problems with many browser which didn't support gzipped 
> javascript.

Sounds reasonable.

Remy



Re: [PATCH] fix compression="on" option on coyote connector

Posted by Henri Gomez <hg...@apache.org>.
Steve Appling a écrit :

> Henri Gomez wrote:
> 
>>Are you sure you want to compress content less than 2k ?
>>
>>BTW, you could use compression property for your purpose.
> 
> 
> You are correct, the property works fine.
> 
> 
>>>3) Added application/x-javascript as a default compressable
>>>type.  Now it allows all mime types starting with "text/", not just the
>>>three previously specified.
>>
>>Nope there is problems with many browser which didn't support gzipped
>>javascript.
> 
> 
> Are there really browsers that send "Accept-Encoding: gzip", but don't
> really accept it?  I was not aware of that. Which ones do this?

Of course, you could make some search on google for it.
Also there is still problem to get pdf on gzip streams (may be more a 
problem with acrobat browser integration).

>>I submitted part of this code after reviewing what HTTPD team does on
>>mod_deflate, and I feel you could trust them isn't it ?
> 
> 
> I'm sorry, I didn't understand that.  What was submitted to whom?

I suggested the idea to Remy who wrote the code.
I make some change after taking a look at mod_deflate code.

mod_deflate has existed before gzip support in coyote


RE: [PATCH] fix compression="on" option on coyote connector

Posted by Steve Appling <sa...@mindspring.com>.
Stefan Bodewig wrote:
> In short, Netscape 4 probably won't work at all, MSIE seems to have
> trouble unless you have a certain fix installed.  All others should
> work (even for the JavaScript case).
>
> The mod_gzip author recommends not compressing anything for Netscape 4
> at all.
>

There is a noCompressionUserAgents list in the Http11Processor which could
be used to stop compression for certain user agents, but I don't see where
it is ever initialized.  Can the noCompressionUserAgents list or the
compressableMimeTypes list be customized in a config file?  I see setter
methods for these lists, but don't see where they are ever called.


---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-dev-help@jakarta.apache.org


RE: [PATCH] fix compression="on" option on coyote connector

Posted by Steve Appling <sa...@mindspring.com>.
Stefan Bodewig wrote:
> In short, Netscape 4 probably won't work at all, MSIE seems to have
> trouble unless you have a certain fix installed.  All others should
> work (even for the JavaScript case).
>
> The mod_gzip author recommends not compressing anything for Netscape 4
> at all.
>

There is a noCompressionUserAgents list in the Http11Processor which could
be used to stop compression for certain user agents, but I don't see where
it is ever initialized.  Can the noCompressionUserAgents list or the
compressableMimeTypes list be customized in a config file?  I see setter
methods for these lists, but don't see where they are ever called.


Re: [PATCH] fix compression="on" option on coyote connector

Posted by Stefan Bodewig <bo...@apache.org>.
On Wed, 17 Sep 2003, Steve Appling <sa...@mindspring.com> wrote:

> Are there really browsers that send "Accept-Encoding: gzip", but
> don't really accept it?

This is from mod_gzip:
<http://www.schroepl.net/projekte/mod_gzip/browser.htm>.

> I was not aware of that. Which ones do this?

In short, Netscape 4 probably won't work at all, MSIE seems to have
trouble unless you have a certain fix installed.  All others should
work (even for the JavaScript case).

The mod_gzip author recommends not compressing anything for Netscape 4
at all.

Stefan

---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-dev-help@jakarta.apache.org


Re: [PATCH] fix compression="on" option on coyote connector

Posted by Stefan Bodewig <bo...@apache.org>.
On Wed, 17 Sep 2003, Steve Appling <sa...@mindspring.com> wrote:

> Are there really browsers that send "Accept-Encoding: gzip", but
> don't really accept it?

This is from mod_gzip:
<http://www.schroepl.net/projekte/mod_gzip/browser.htm>.

> I was not aware of that. Which ones do this?

In short, Netscape 4 probably won't work at all, MSIE seems to have
trouble unless you have a certain fix installed.  All others should
work (even for the JavaScript case).

The mod_gzip author recommends not compressing anything for Netscape 4
at all.

Stefan

Re: [PATCH] fix compression="on" option on coyote connector

Posted by Henri Gomez <hg...@apache.org>.
Steve Appling a écrit :

> Henri Gomez wrote:
> 
>>Are you sure you want to compress content less than 2k ?
>>
>>BTW, you could use compression property for your purpose.
> 
> 
> You are correct, the property works fine.
> 
> 
>>>3) Added application/x-javascript as a default compressable
>>>type.  Now it allows all mime types starting with "text/", not just the
>>>three previously specified.
>>
>>Nope there is problems with many browser which didn't support gzipped
>>javascript.
> 
> 
> Are there really browsers that send "Accept-Encoding: gzip", but don't
> really accept it?  I was not aware of that. Which ones do this?

Of course, you could make some search on google for it.
Also there is still problem to get pdf on gzip streams (may be more a 
problem with acrobat browser integration).

>>I submitted part of this code after reviewing what HTTPD team does on
>>mod_deflate, and I feel you could trust them isn't it ?
> 
> 
> I'm sorry, I didn't understand that.  What was submitted to whom?

I suggested the idea to Remy who wrote the code.
I make some change after taking a look at mod_deflate code.

mod_deflate has existed before gzip support in coyote


---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-dev-help@jakarta.apache.org


RE: [PATCH] fix compression="on" option on coyote connector

Posted by Steve Appling <sa...@mindspring.com>.
Henri Gomez wrote:
> Are you sure you want to compress content less than 2k ?
>
> BTW, you could use compression property for your purpose.

You are correct, the property works fine.

> > 3) Added application/x-javascript as a default compressable
> >type.  Now it allows all mime types starting with "text/", not just the
> >three previously specified.
>
> Nope there is problems with many browser which didn't support gzipped
> javascript.

Are there really browsers that send "Accept-Encoding: gzip", but don't
really accept it?  I was not aware of that. Which ones do this?


> I submitted part of this code after reviewing what HTTPD team does on
> mod_deflate, and I feel you could trust them isn't it ?

I'm sorry, I didn't understand that.  What was submitted to whom?


---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-dev-help@jakarta.apache.org


RE: [PATCH] fix compression="on" option on coyote connector

Posted by Steve Appling <sa...@mindspring.com>.
Henri Gomez wrote:
> Are you sure you want to compress content less than 2k ?
>
> BTW, you could use compression property for your purpose.

You are correct, the property works fine.

> > 3) Added application/x-javascript as a default compressable
> >type.  Now it allows all mime types starting with "text/", not just the
> >three previously specified.
>
> Nope there is problems with many browser which didn't support gzipped
> javascript.

Are there really browsers that send "Accept-Encoding: gzip", but don't
really accept it?  I was not aware of that. Which ones do this?


> I submitted part of this code after reviewing what HTTPD team does on
> mod_deflate, and I feel you could trust them isn't it ?

I'm sorry, I didn't understand that.  What was submitted to whom?


Re: [PATCH] fix compression="on" option on coyote connector

Posted by Henri Gomez <hg...@apache.org>.
Steve Appling a écrit :
> Currently the option for compression="on" in the coyote connector is broken
> (see bug 18073).  The solution presented in the patches attached to that bug
> seemed overly complicated.  Here is an alternate patch that also fixes the
> problem.
> 
> This patch changes 3 things:
> 1) Decreases the minimum compression size to 1k - this seemed to help with
> my particular application.  There was a lot in the range of 1-2k.

Are you sure you want to compress content less than 2k ?

BTW, you could use compression property for your purpose.

> 2) Checks only that the content type starts with an entry in the
> compressableMimeTypes list instead of checking equality.  This is the real
> bug fix since the contentType also includes the character encoding
> information.

That's the way it's done on Apache HTTPD mod_deflate.

> 3) Added application/x-javascript as a default compressable type.  Now it
> allows all mime types starting with "text/", not just the three previously
> specified.

Nope there is problems with many browser which didn't support gzipped 
javascript.


I submitted part of this code after reviewing what HTTPD team does on 
mod_deflate, and I feel you could trust them isn't it ?




Re: [PATCH] fix compression="on" option on coyote connector

Posted by Henri Gomez <hg...@apache.org>.
Steve Appling a écrit :
> Currently the option for compression="on" in the coyote connector is broken
> (see bug 18073).  The solution presented in the patches attached to that bug
> seemed overly complicated.  Here is an alternate patch that also fixes the
> problem.
> 
> This patch changes 3 things:
> 1) Decreases the minimum compression size to 1k - this seemed to help with
> my particular application.  There was a lot in the range of 1-2k.

Are you sure you want to compress content less than 2k ?

BTW, you could use compression property for your purpose.

> 2) Checks only that the content type starts with an entry in the
> compressableMimeTypes list instead of checking equality.  This is the real
> bug fix since the contentType also includes the character encoding
> information.

That's the way it's done on Apache HTTPD mod_deflate.

> 3) Added application/x-javascript as a default compressable type.  Now it
> allows all mime types starting with "text/", not just the three previously
> specified.

Nope there is problems with many browser which didn't support gzipped 
javascript.


I submitted part of this code after reviewing what HTTPD team does on 
mod_deflate, and I feel you could trust them isn't it ?




---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-dev-help@jakarta.apache.org


RE: [PATCH] fix compression="on" option on coyote connector

Posted by Steve Appling <sa...@mindspring.com>.
OK - here's a simple patch that just fixes the problem and doesn't change
anything controversial :)

I will be glad to make the changes to include two new attributes on the
connector to specify the list of uncompressible mime types and
uncompressible user agents if a committer is willing to consider it.

Index: Http11Processor.java
===================================================================
RCS file:
/home/cvspublic/jakarta-tomcat-connectors/http11/src/java/org/apache/coyote/
http11/Http11Processor.java,v
retrieving revision 1.78
diff -r1.78 Http11Processor.java
462a463,478
>     /**
>      * Checks if any entry in the string array starts with the specified
value
>      *
>      * @param sArray the StringArray
>      * @param value string
>      */
>     private boolean startsWithStringArray(String sArray[], String value) {
>         if (value == null)
>            return false;
>         for (int i = 0; i < sArray.length; i++) {
>             if (value.startsWith(sArray[i])) {
>                 return true;
>             }
>         }
>         return false;
>     }
1216,1217c1232,1233
<             if (compressableMimeTypes != null)
<                 return (inStringArray(compressableMimeTypes,
response.getContentType()));
---
>             if (compressableMimeTypes != null)
>                return (startsWithStringArray(compressableMimeTypes,
response.getContentType()));


---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-dev-help@jakarta.apache.org


RE: [PATCH] fix compression="on" option on coyote connector

Posted by Steve Appling <sa...@mindspring.com>.
OK - here's a simple patch that just fixes the problem and doesn't change
anything controversial :)

I will be glad to make the changes to include two new attributes on the
connector to specify the list of uncompressible mime types and
uncompressible user agents if a committer is willing to consider it.

Index: Http11Processor.java
===================================================================
RCS file:
/home/cvspublic/jakarta-tomcat-connectors/http11/src/java/org/apache/coyote/
http11/Http11Processor.java,v
retrieving revision 1.78
diff -r1.78 Http11Processor.java
462a463,478
>     /**
>      * Checks if any entry in the string array starts with the specified
value
>      *
>      * @param sArray the StringArray
>      * @param value string
>      */
>     private boolean startsWithStringArray(String sArray[], String value) {
>         if (value == null)
>            return false;
>         for (int i = 0; i < sArray.length; i++) {
>             if (value.startsWith(sArray[i])) {
>                 return true;
>             }
>         }
>         return false;
>     }
1216,1217c1232,1233
<             if (compressableMimeTypes != null)
<                 return (inStringArray(compressableMimeTypes,
response.getContentType()));
---
>             if (compressableMimeTypes != null)
>                return (startsWithStringArray(compressableMimeTypes,
response.getContentType()));