svn commit: r1824119 - in /tomcat/trunk/java/org/apache/coyote/http2: Http2AsyncParser.java Http2Parser.java

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

svn commit: r1824119 - in /tomcat/trunk/java/org/apache/coyote/http2: Http2AsyncParser.java Http2Parser.java

remm
Author: remm
Date: Tue Feb 13 12:19:27 2018
New Revision: 1824119

URL: http://svn.apache.org/viewvc?rev=1824119&view=rev
Log:
Refactoring of swallow to reduce duplication.

Modified:
    tomcat/trunk/java/org/apache/coyote/http2/Http2AsyncParser.java
    tomcat/trunk/java/org/apache/coyote/http2/Http2Parser.java

Modified: tomcat/trunk/java/org/apache/coyote/http2/Http2AsyncParser.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/coyote/http2/Http2AsyncParser.java?rev=1824119&r1=1824118&r2=1824119&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/coyote/http2/Http2AsyncParser.java (original)
+++ tomcat/trunk/java/org/apache/coyote/http2/Http2AsyncParser.java Tue Feb 13 12:19:27 2018
@@ -88,39 +88,6 @@ class Http2AsyncParser extends Http2Pars
         }
     }
 
-    @Override
-    protected void swallow(int streamId, int len, boolean mustBeZero, ByteBuffer buffer)
-            throws IOException, ConnectionException {
-        if (log.isDebugEnabled()) {
-            log.debug(sm.getString("http2Parser.swallow.debug", connectionId,
-                    Integer.toString(streamId), Integer.toString(len)));
-        }
-        if (len == 0) {
-            return;
-        }
-        if (!mustBeZero) {
-            buffer.position(buffer.position() + len);
-        } else {
-            int read = 0;
-            byte[] buf = new byte[1024];
-            while (read < len) {
-                int thisTime = Math.min(buf.length, len - read);
-                buffer.get(buf, 0, thisTime);
-                // Validate the padding is zero since receiving non-zero padding
-                // is a strong indication of either a faulty client or a server
-                // side bug.
-                for (int i = 0; i < thisTime; i++) {
-                    if (buf[i] != 0) {
-                        throw new ConnectionException(sm.getString("http2Parser.nonZeroPadding",
-                                connectionId, Integer.toString(streamId)), Http2Error.PROTOCOL_ERROR);
-                    }
-                }
-                read += thisTime;
-            }
-        }
-    }
-
-
     private class FrameCompletionCheck implements CompletionCheck {
 
         private final FrameCompletionHandler handler;

Modified: tomcat/trunk/java/org/apache/coyote/http2/Http2Parser.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/coyote/http2/Http2Parser.java?rev=1824119&r1=1824118&r2=1824119&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/coyote/http2/Http2Parser.java (original)
+++ tomcat/trunk/java/org/apache/coyote/http2/Http2Parser.java Tue Feb 13 12:19:27 2018
@@ -527,23 +527,31 @@ class Http2Parser {
         if (len == 0) {
             return;
         }
-        int read = 0;
-        byte[] buffer = new byte[1024];
-        while (read < len) {
-            int thisTime = Math.min(buffer.length, len - read);
-            input.fill(true, buffer, 0, thisTime);
-            if (mustBeZero) {
-                // Validate the padding is zero since receiving non-zero padding
-                // is a strong indication of either a faulty client or a server
-                // side bug.
-                for (int i = 0; i < thisTime; i++) {
-                    if (buffer[i] != 0) {
-                        throw new ConnectionException(sm.getString("http2Parser.nonZeroPadding",
-                                connectionId, Integer.toString(streamId)), Http2Error.PROTOCOL_ERROR);
+        if (!mustBeZero && byteBuffer != null) {
+            byteBuffer.position(byteBuffer.position() + len);
+        } else {
+            int read = 0;
+            byte[] buffer = new byte[1024];
+            while (read < len) {
+                int thisTime = Math.min(buffer.length, len - read);
+                if (byteBuffer == null) {
+                    input.fill(true, buffer, 0, thisTime);
+                } else {
+                    byteBuffer.get(buffer, 0, thisTime);
+                }
+                if (mustBeZero) {
+                    // Validate the padding is zero since receiving non-zero padding
+                    // is a strong indication of either a faulty client or a server
+                    // side bug.
+                    for (int i = 0; i < thisTime; i++) {
+                        if (buffer[i] != 0) {
+                            throw new ConnectionException(sm.getString("http2Parser.nonZeroPadding",
+                                    connectionId, Integer.toString(streamId)), Http2Error.PROTOCOL_ERROR);
+                        }
                     }
                 }
+                read += thisTime;
             }
-            read += thisTime;
         }
     }
 



---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]