tomcat-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From hgo...@apache.org
Subject cvs commit: jakarta-tomcat-connectors/http11/src/java/org/apache/coyote/http11 Http11Processor.java
Date Thu, 19 Dec 2002 09:13:16 GMT
hgomez      2002/12/19 01:13:16

  Modified:    http11/src/java/org/apache/coyote/http11
                        Http11Processor.java
  Log:
  If content is allready gzipped, no need to recompress it
  
  Revision  Changes    Path
  1.49      +26 -10    jakarta-tomcat-connectors/http11/src/java/org/apache/coyote/http11/Http11Processor.java
  
  Index: Http11Processor.java
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat-connectors/http11/src/java/org/apache/coyote/http11/Http11Processor.java,v
  retrieving revision 1.48
  retrieving revision 1.49
  diff -u -r1.48 -r1.49
  --- Http11Processor.java	18 Dec 2002 20:36:58 -0000	1.48
  +++ Http11Processor.java	19 Dec 2002 09:13:16 -0000	1.49
  @@ -257,6 +257,12 @@
   
   
       /**
  +     * Minimum contentsize to make compression.
  +     */
  +    protected int compressionMinSize = 2048;
  +
  +
  +    /**
        * Host name (used to avoid useless B2C conversion on the host name).
        */
       protected char[] hostNameC = new char[0];
  @@ -976,17 +982,27 @@
                   request.getMimeHeaders().getValue("accept-encoding");
               if ((acceptEncodingMB != null) 
                   && (acceptEncodingMB.indexOf("gzip") != -1)) {
  -                // Check content-type
  -                if (compressionLevel == 1) {
  -                    int contentLength = response.getContentLength();
  -                    // FIXME: Make the value configurable
  -                    if ((contentLength == -1) || (contentLength > 2048)) {
  -                        useCompression = 
  -                            response.getContentType().startsWith("text/");
  -                    }
  -                } else {
  -                    useCompression = true;
  +                	
  +                // Check in content is not allready gzipped
  +                MessageBytes contentEncodingMB =
  +					response.getMimeHeaders().getValue("Content-Encoding");
  +					
  +            	if ((contentEncodingMB == null) 
  +                	|| (contentEncodingMB.indexOf("gzip") == -1))
  +                {			
  +	                // Check content-type
  +	                if (compressionLevel == 1) {
  +	                    int contentLength = response.getContentLength();
  +	                    // FIXME: Make the value configurable
  +	                    if ((contentLength == -1) || (contentLength > compressionMinSize))
{
  +	                        useCompression = 
  +	                            response.getContentType().startsWith("text/");
  +	                    }
  +	                } else {
  +	                    useCompression = true;
  +	                }
                   }
  +                
                   // Change content-length to -1 to force chunking
                   if (useCompression) {
                       response.setContentLength(-1);
  
  
  

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


Mime
View raw message