You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by ma...@apache.org on 2009/07/06 01:03:24 UTC

svn commit: r791334 - in /tomcat/container/tc5.5.x: catalina/src/share/org/apache/catalina/connector/LocalStrings.properties catalina/src/share/org/apache/catalina/connector/Request.java webapps/docs/changelog.xml

Author: markt
Date: Sun Jul  5 23:03:23 2009
New Revision: 791334

URL: http://svn.apache.org/viewvc?rev=791334&view=rev
Log:
Fix https://issues.apache.org/bugzilla/show_bug.cgi?id=37794
Add support for reading POST parameters when using chunked encoding

Modified:
    tomcat/container/tc5.5.x/catalina/src/share/org/apache/catalina/connector/LocalStrings.properties
    tomcat/container/tc5.5.x/catalina/src/share/org/apache/catalina/connector/Request.java
    tomcat/container/tc5.5.x/webapps/docs/changelog.xml

Modified: tomcat/container/tc5.5.x/catalina/src/share/org/apache/catalina/connector/LocalStrings.properties
URL: http://svn.apache.org/viewvc/tomcat/container/tc5.5.x/catalina/src/share/org/apache/catalina/connector/LocalStrings.properties?rev=791334&r1=791333&r2=791334&view=diff
==============================================================================
--- tomcat/container/tc5.5.x/catalina/src/share/org/apache/catalina/connector/LocalStrings.properties (original)
+++ tomcat/container/tc5.5.x/catalina/src/share/org/apache/catalina/connector/LocalStrings.properties Sun Jul  5 23:03:23 2009
@@ -58,6 +58,8 @@
 coyoteRequest.attributeEvent=Exception thrown by attributes event listener
 coyoteRequest.parseParameters=Exception thrown whilst processing POSTed parameters
 coyoteRequest.postTooLarge=Parameters were not parsed because the size of the posted data was too big. Use the maxPostSize attribute of the connector to resolve this if the application should accept large POSTs.
+coyoteRequest.chunkedPostTooLarge=Parameters were not parsed because the size of the posted data was too big. Because this request was a chunked request, it could not be processed further. Use the maxPostSize attribute of the connector to resolve this if the application should accept large POSTs.
+
 requestFacade.nullRequest=Null request object
 responseFacade.nullResponse=Null response object
 

Modified: tomcat/container/tc5.5.x/catalina/src/share/org/apache/catalina/connector/Request.java
URL: http://svn.apache.org/viewvc/tomcat/container/tc5.5.x/catalina/src/share/org/apache/catalina/connector/Request.java?rev=791334&r1=791333&r2=791334&view=diff
==============================================================================
--- tomcat/container/tc5.5.x/catalina/src/share/org/apache/catalina/connector/Request.java (original)
+++ tomcat/container/tc5.5.x/catalina/src/share/org/apache/catalina/connector/Request.java Sun Jul  5 23:03:23 2009
@@ -46,6 +46,7 @@
 import javax.servlet.http.HttpSession;
 
 import org.apache.tomcat.util.buf.B2CConverter;
+import org.apache.tomcat.util.buf.ByteChunk;
 import org.apache.tomcat.util.buf.MessageBytes;
 import org.apache.tomcat.util.buf.StringCache;
 import org.apache.tomcat.util.http.Cookies;
@@ -2403,6 +2404,20 @@
                 context.getLogger().warn
                     (sm.getString("coyoteRequest.parseParameters"), t);
             }
+        } else if ("chunked".equalsIgnoreCase(
+                coyoteRequest.getHeader("transfer-encoding"))) {
+            byte[] formData = null;
+            try {
+                formData = readChunkedPostBody();
+            } catch (IOException e) {
+                // Client disconnect
+                if (context.getLogger().isDebugEnabled()) {
+                    context.getLogger().debug(
+                            sm.getString("coyoteRequest.parseParameters"), e);
+                }
+                return;
+            }
+            parameters.processParameters(formData, 0, formData.length);
         }
 
     }
@@ -2428,6 +2443,38 @@
 
 
     /**
+     * Read chunked post body.
+     */
+    protected byte[] readChunkedPostBody() throws IOException {
+        ByteChunk body = new ByteChunk();
+        
+        byte[] buffer = new byte[CACHED_POST_LEN];
+        
+        int len = 0;
+        while (len > -1) {
+            len = getStream().read(buffer, 0, CACHED_POST_LEN);
+            if (connector.getMaxPostSize() > 0 &&
+                    (body.getLength() + len) > connector.getMaxPostSize()) {
+                // Too much data
+                throw new IllegalArgumentException(
+                        sm.getString("coyoteRequest.chunkedPostTooLarge"));
+            }
+            if (len > 0) {
+                body.append(buffer, 0, len);
+            }
+        }
+        if (body.getLength() < body.getBuffer().length) {
+            int length = body.getLength();
+            byte[] result = new byte[length];
+            System.arraycopy(body.getBuffer(), 0, result, 0, length);
+            return result;
+        } else {
+            return body.getBuffer();
+        }
+    }
+    
+    
+    /**
      * Parse request locales.
      */
     protected void parseLocales() {

Modified: tomcat/container/tc5.5.x/webapps/docs/changelog.xml
URL: http://svn.apache.org/viewvc/tomcat/container/tc5.5.x/webapps/docs/changelog.xml?rev=791334&r1=791333&r2=791334&view=diff
==============================================================================
--- tomcat/container/tc5.5.x/webapps/docs/changelog.xml (original)
+++ tomcat/container/tc5.5.x/webapps/docs/changelog.xml Sun Jul  5 23:03:23 2009
@@ -72,6 +72,10 @@
         unavailable during context destruction. (markt)
       </fix>
       <fix>
+        <bug>37794</bug>: Handle POSTed parameters when sent with chunked
+        encoding. (markt)
+      </fix>
+      <fix>
         <bug>38553</bug>: A lack of certificates is normal if a user doesn't
         have a certificate. Return a 401 rather than a 400 in this case. (markt)
       </fix>



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