Port r486217, which was applied to connectors, but has
authorrjung <rjung@13f79535-47bb-0310-9956-ffa450edef68>
Fri, 19 Sep 2008 19:12:59 +0000 (19:12 +0000)
committerrjung <rjung@13f79535-47bb-0310-9956-ffa450edef68>
Fri, 19 Sep 2008 19:12:59 +0000 (19:12 +0000)
never been applied to 6.0 and trunk.

git-svn-id: https://svn.apache.org/repos/asf/tomcat/trunk@697192 13f79535-47bb-0310-9956-ffa450edef68

java/org/apache/jk/common/JkInputStream.java

index 6186a2c..7c58ddc 100644 (file)
@@ -52,6 +52,7 @@ public class JkInputStream implements InputBuffer, OutputBuffer {
     private boolean isFirst = true;
     private boolean isReplay = false;
     private boolean isReadRequired = false;
+    private int packetSize = AjpConstants.MAX_PACKET_SIZE;
 
     static {
         // Make certain HttpMessages is loaded for SecurityManager
@@ -64,14 +65,19 @@ public class JkInputStream implements InputBuffer, OutputBuffer {
 
     public JkInputStream(MsgContext context, int bsize) {
         mc = context;
-        bodyMsg = new MsgAjp(bsize);
-        outputMsg = new MsgAjp(bsize);
+        // Never use less than the default maximum packet size.
+        if (bsize < AjpConstants.MAX_PACKET_SIZE)
+            this.packetSize = AjpConstants.MAX_PACKET_SIZE;
+        else
+            this.packetSize = bsize;
+        bodyMsg = new MsgAjp(this.packetSize);
+        outputMsg = new MsgAjp(this.packetSize);
     }
     /**
      * @deprecated
      */
     public JkInputStream(MsgContext context) {
-        this(context, 8*1024);
+        this(context, AjpConstants.MAX_PACKET_SIZE);
     }
 
     // -------------------- Jk specific methods --------------------
@@ -244,7 +250,8 @@ public class JkInputStream implements InputBuffer, OutputBuffer {
         // Why not use outBuf??
         bodyMsg.reset();
         bodyMsg.appendByte(AjpConstants.JK_AJP13_GET_BODY_CHUNK);
-        bodyMsg.appendInt(AjpConstants.MAX_READ_SIZE);
+        // Adjust allowed size if packetSize != default (AjpConstants.MAX_PACKET_SIZE)
+        bodyMsg.appendInt(AjpConstants.MAX_READ_SIZE + packetSize - AjpConstants.MAX_PACKET_SIZE);
         
         if( log.isDebugEnabled() )
             log.debug("refillReadBuffer " + Thread.currentThread());