tomcat-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mt...@apache.org
Subject svn commit: r479317 - in /tomcat/tc6.0.x/trunk/java/org/apache/coyote/ajp: AjpAprProcessor.java AjpProcessor.java Constants.java
Date Sun, 26 Nov 2006 09:29:16 GMT
Author: mturk
Date: Sun Nov 26 01:29:15 2006
New Revision: 479317

URL: http://svn.apache.org/viewvc?view=rev&rev=479317
Log:
Compress outgoing response headers according to the
AJP13 protocol specification.

Modified:
    tomcat/tc6.0.x/trunk/java/org/apache/coyote/ajp/AjpAprProcessor.java
    tomcat/tc6.0.x/trunk/java/org/apache/coyote/ajp/AjpProcessor.java
    tomcat/tc6.0.x/trunk/java/org/apache/coyote/ajp/Constants.java

Modified: tomcat/tc6.0.x/trunk/java/org/apache/coyote/ajp/AjpAprProcessor.java
URL: http://svn.apache.org/viewvc/tomcat/tc6.0.x/trunk/java/org/apache/coyote/ajp/AjpAprProcessor.java?view=diff&rev=479317&r1=479316&r2=479317
==============================================================================
--- tomcat/tc6.0.x/trunk/java/org/apache/coyote/ajp/AjpAprProcessor.java (original)
+++ tomcat/tc6.0.x/trunk/java/org/apache/coyote/ajp/AjpAprProcessor.java Sun Nov 26 01:29:15
2006
@@ -960,9 +960,15 @@
         // Other headers
         int numHeaders = headers.size();
         responseHeaderMessage.appendInt(numHeaders);
-        for (int i = 0; i < numHeaders; i++) {
+        for (int i = 0; i < numHeaders; i++) {            
             MessageBytes hN = headers.getName(i);
-            responseHeaderMessage.appendBytes(hN);
+            int hC = Constants.getResponseAjpIndex(hN.toString());
+            if (hC > 0) {
+                responseHeaderMessage.appendInt(hC);
+            }
+            else {
+                responseHeaderMessage.appendBytes(hN);
+            }
             MessageBytes hV=headers.getValue(i);
             responseHeaderMessage.appendBytes(hV);
         }

Modified: tomcat/tc6.0.x/trunk/java/org/apache/coyote/ajp/AjpProcessor.java
URL: http://svn.apache.org/viewvc/tomcat/tc6.0.x/trunk/java/org/apache/coyote/ajp/AjpProcessor.java?view=diff&rev=479317&r1=479316&r2=479317
==============================================================================
--- tomcat/tc6.0.x/trunk/java/org/apache/coyote/ajp/AjpProcessor.java (original)
+++ tomcat/tc6.0.x/trunk/java/org/apache/coyote/ajp/AjpProcessor.java Sun Nov 26 01:29:15
2006
@@ -929,7 +929,13 @@
         responseHeaderMessage.appendInt(numHeaders);
         for (int i = 0; i < numHeaders; i++) {
             MessageBytes hN = headers.getName(i);
-            responseHeaderMessage.appendBytes(hN);
+            int hC = Constants.getResponseAjpIndex(hN.toString());
+            if (hC > 0) {
+                responseHeaderMessage.appendInt(hC);
+            }
+            else {
+                responseHeaderMessage.appendBytes(hN);
+            }
             MessageBytes hV=headers.getValue(i);
             responseHeaderMessage.appendBytes(hV);
         }

Modified: tomcat/tc6.0.x/trunk/java/org/apache/coyote/ajp/Constants.java
URL: http://svn.apache.org/viewvc/tomcat/tc6.0.x/trunk/java/org/apache/coyote/ajp/Constants.java?view=diff&rev=479317&r1=479316&r2=479317
==============================================================================
--- tomcat/tc6.0.x/trunk/java/org/apache/coyote/ajp/Constants.java (original)
+++ tomcat/tc6.0.x/trunk/java/org/apache/coyote/ajp/Constants.java Sun Nov 26 01:29:15 2006
@@ -17,6 +17,9 @@
 
 package org.apache.coyote.ajp;
 
+import java.lang.IndexOutOfBoundsException;
+import java.util.Hashtable;
+import java.util.Locale;
 import org.apache.tomcat.util.buf.ByteChunk;
 
 
@@ -67,6 +70,7 @@
     public static final int SC_RESP_SERVLET_ENGINE      = 0xA009;
     public static final int SC_RESP_STATUS              = 0xA00A;
     public static final int SC_RESP_WWW_AUTHENTICATE    = 0xA00B;
+    public static final int SC_RESP_AJP13_MAX           = 11;
 
     // Integer codes for common (optional) request attribute names
     public static final byte SC_A_CONTEXT       = 1;  // XXX Unused
@@ -179,7 +183,47 @@
             "user-agent"
     };
 
+    // Translates integer codes to response header names
+    public static final String []responseTransArray = {
+            "content-type",
+            "content-language",
+            "content-length",
+            "date",
+            "last-modified",
+            "location",
+            "set-cookie",
+            "set-cookie2",
+            "servlet-engine",
+            "status",
+            "www-authenticate"
+    };
+
+    private static final Hashtable<String,Integer>  responseTransHash =
+        new Hashtable<String,Integer>(20);
+
+    static {
+        try {
+            int i;
+            for (i = 0; i < SC_RESP_AJP13_MAX; i++) {
+                responseTransHash.put(responseTransArray[i],
+                                      new Integer(0xA001 + i));
+            }
+        }
+        catch (Exception e) {
+            // Do nothing
+        }
+    }    
+
+    public static final int getResponseAjpIndex(String header)
+    {
+        Integer i = responseTransHash.get(header.toLowerCase(Locale.US));
+        if (i == null)
+            return 0;
+        else
+            return i.intValue();
+    }
 
+    
     /**
      * CRLF.
      */



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


Mime
View raw message