Add the ability to swallow input by specifying a null chunk
authormarkt <markt@13f79535-47bb-0310-9956-ffa450edef68>
Tue, 23 Aug 2011 16:22:03 +0000 (16:22 +0000)
committermarkt <markt@13f79535-47bb-0310-9956-ffa450edef68>
Tue, 23 Aug 2011 16:22:03 +0000 (16:22 +0000)
git-svn-id: https://svn.apache.org/repos/asf/tomcat/trunk@1160776 13f79535-47bb-0310-9956-ffa450edef68

java/org/apache/coyote/ajp/AbstractAjpProcessor.java

index 799509e..bc2e58a 100644 (file)
@@ -1010,9 +1010,9 @@ public abstract class AbstractAjpProcessor<S> extends AbstractProcessor<S> {
      */
     protected class SocketInputBuffer implements InputBuffer {
 
-
         /**
-         * Read bytes into the specified chunk.
+         * Read bytes into the specified chunk. If no chunk is specified, the
+         * bytes are swallowed.
          */
         @Override
         public int doRead(ByteChunk chunk, Request req)
@@ -1033,7 +1033,9 @@ public abstract class AbstractAjpProcessor<S> extends AbstractProcessor<S> {
             }
             ByteChunk bc = bodyBytes.getByteChunk();
             bodyBytesRead += bc.getLength();
-            chunk.setBytes(bc.getBuffer(), bc.getStart(), bc.getLength());
+            if (chunk != null) {
+                chunk.setBytes(bc.getBuffer(), bc.getStart(), bc.getLength());
+            }
             empty = true;
             return bc.getLength();
         }