2 Replies Latest reply on May 11, 2005 2:28 PM by teej

    How is HTTP compression enabled on HTTP/1.1 connector?

    teej Newbie

      Using JBoss 4.0.1 with Tomcat 5.0.28, and the 'default' configuration.

      Cannot get the HTTP connector to perform compression despite having the correct entries in Tomcat's server.xml.

      As you'll see from my investigation below I've looked into the source-code and cannot find any clues. Googling hasn't helped so far either.

      Any ideas?
      TJ

      <Service name="jboss.web"
       className="org.jboss.web.tomcat.tc5.StandardService">
      
      <Connector port="80" address="84.x.y.z"
       compression="force" compressionMinSize="256"
       compressableMimeType="text/html,text/xml,text/plain"
       maxThreads="150" minSpareThreads="25" maxSpareThreads="75"
       enableLookups="false" redirectPort="8443" acceptCount="100"
       connectionTimeout="20000" disableUploadTimeout="true"/>


      The connector being loaded is:
      2005-05-11 17:18:25,639 INFO [org.apache.coyote.http11.Http11Protocol] Starting Coyote HTTP/1.1 on http-84.x.y.z-80


      I'm testing for compresion using the port80 tool at http://www.port80software.com/tools/compresscheck which has just helped get IIS6 performing gzip compression in response to HTTP/1.1 "Accept-Encoding: gzip, deflate" request headers.

      The connector documentation explicitly shows that compression is supported: http://jakarta.apache.org/tomcat/tomcat-5.0-doc/catalina/docs/api/org/apache/coyote/http11/Http11Processor.html#setCompressableMimeTypes(java.lang.String)

      Source code shows it too:

      Http11Protocol.java
      /**
       * Compression value.
       */
       private String compression = "off";
       private String noCompressionUserAgents = null;
       private String restrictedUserAgents = null;
       private String compressableMimeTypes = "text/html,text/xml,text/plain";
       private int compressionMinSize = 2048;
      
      
       public void setCompression(String valueS) {
       compression = valueS;
       setAttribute("compression", valueS);
       }
      


      Http11Processor.java
      protected void prepareResponse() {
      
       if (useCompression) {
       outputBuffer.addActiveFilter(outputFilters[Constants.GZIP_FILTER]);
       // FIXME: Make content-encoding generation dynamic
       response.setHeader("Content-Encoding", "gzip");
       // Make Proxies happy via Vary (from mod_deflate)
       response.setHeader("Vary", "Accept-Encoding");
       }
      




        • 1. Re: How is HTTP compression enabled on HTTP/1.1 connector?
          teej Newbie

          Follow-up

          I enabled logging for the connector by adding a connector category entry to the Log4J properties and it shows that the compression attributes are being set in the Http11Protocol class.

          jboss-4.0.1\server\default\conf\log4j.xml

          <!-- ================ -->
           <!-- Limit categories -->
           <!-- ================ -->
          
           <!-- Follow the actions of the HTTP/1.1 connector -->
           <category name="org.apache.coyote.http11.Http11Protocol">
           <priority value="TRACE"/>
           </category>
          


          The attributes are correctly read from Tomcat's server.xml file:

          [org.apache.coyote.http11.Http11Protocol] Attribute soLinger: -1
          [org.apache.coyote.http11.Http11Protocol] Attribute soTimeout: 60000
          [org.apache.coyote.http11.Http11Protocol] Attribute serverSoTimeout: 0
          [org.apache.coyote.http11.Http11Protocol] Attribute tcpNoDelay: true
          [org.apache.coyote.http11.Http11Protocol] Attribute jkHome: D:\Server\Java\jboss-4.0.1\server\default
          [org.apache.coyote.http11.Http11Protocol] Attribute secure: false
          [org.apache.coyote.http11.Http11Protocol] Attribute compressionMinSize: 256
          [org.apache.coyote.http11.Http11Protocol] Attribute maxThreads: 150
          [org.apache.coyote.http11.Http11Protocol] Attribute backlog: 100
          [org.apache.coyote.http11.Http11Protocol] Attribute minSpareThreads: 25
          [org.apache.coyote.http11.Http11Protocol] Attribute address: /84.12.34.245
          [org.apache.coyote.http11.Http11Protocol] Attribute redirectPort: 8443
          [org.apache.coyote.http11.Http11Protocol] Attribute port: 80
          [org.apache.coyote.http11.Http11Protocol] Attribute maxSpareThreads: 75
          [org.apache.coyote.http11.Http11Protocol] Attribute compressableMimeTypes: text/html,text/xml,text/plain
          [org.apache.coyote.http11.Http11Protocol] Attribute service: StandardService[jboss.web]
          [org.apache.coyote.http11.Http11Protocol] Attribute enableLookups: false
          [org.apache.coyote.http11.Http11Protocol] Attribute soTimeout: 20000
          [org.apache.coyote.http11.Http11Protocol] Attribute compression: force
          [org.apache.coyote.http11.Http11Protocol] Initializing Coyote HTTP/1.1 on http-84.x.y.z-80
          


          • 2. Re: How is HTTP compression enabled on HTTP/1.1 connector?
            teej Newbie

            It looks like compression may be working after all, but the Port80 compression-testing tool doesn't realise.

            I just ran a manual telnet session to the server...

            GET / HTTP/1.1
            Host: test.domain.name
            Accept: */*
            Accept-Encoding: gzip
            

            ... and got this result:
            HTTP/1.1 200 OK
            X-Powered-By: Servlet 2.4; Tomcat-5.0.28/JBoss-4.0.1 (build: CVSTag=JBoss_4_0_1
            date=200412230944)
            Content-Type: text/html;charset=ISO-8859-1
            Transfer-Encoding: chunked
            Content-Encoding: gzip
            Vary: Accept-Encoding
            Date: Wed, 11 May 2005 18:23:12 GMT
            Server: Apache-Coyote/1.1
            
            a
            ?ï
            fd
            mÅ?Nâ@?@?&????/?#?E¶M4Am?ó&^¿îBä??îà??,?I?vÆ¥?^??ï?ó?m?äè??V?mr?üp?_?b£??zù=$??K
            x?¡u?¢?n°¼ì?]Wt£àRSº??h¿;û#?Né?ê÷éq°?Ñ1R÷j??%ç?Q]?Å??<oµ?e*J?r?
            0
            
            Connection to host lost.