tomcat-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From r...@apache.org
Subject svn commit: r1742139 - /tomcat/trunk/java/org/apache/coyote/http11/Http11InputBuffer.java
Date Tue, 03 May 2016 16:23:04 GMT
Author: remm
Date: Tue May  3 16:23:04 2016
New Revision: 1742139

URL: http://svn.apache.org/viewvc?rev=1742139&view=rev
Log:
Use a single read for the HTTP/2 preface (calling fill otherwise won't work).

Modified:
    tomcat/trunk/java/org/apache/coyote/http11/Http11InputBuffer.java

Modified: tomcat/trunk/java/org/apache/coyote/http11/Http11InputBuffer.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/coyote/http11/Http11InputBuffer.java?rev=1742139&r1=1742138&r2=1742139&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/coyote/http11/Http11InputBuffer.java (original)
+++ tomcat/trunk/java/org/apache/coyote/http11/Http11InputBuffer.java Tue May  3 16:23:04
2016
@@ -410,24 +410,18 @@ public class Http11InputBuffer implement
                     // Switch to the socket timeout.
                     wrapper.setReadTimeout(wrapper.getEndpoint().getSoTimeout());
                 }
-                if (!keptAlive) {
+                if (!keptAlive && pos == 0 && lastValid >= CLIENT_PREFACE_START.length
- 1) {
+                    boolean prefaceMatch = true;
                     for (int i = 0; i < CLIENT_PREFACE_START.length; i++) {
-                        if (i == lastValid) {
-                            // Need more data to know if this is HTTP/2
-                            if (!fill(false)) {
-                                // A read is pending, so no longer in initial state
-                                parsingRequestLinePhase = 1;
-                                return false;
-                            }
-                        }
                         if (CLIENT_PREFACE_START[i] != buf[i]) {
-                            break;
-                        } else if (i == CLIENT_PREFACE_START.length - 1) {
-                            // HTTP/2 preface matched
-                            parsingRequestLinePhase = -1;
-                            return false;
+                            prefaceMatch = false;
                         }
                     }
+                    if (prefaceMatch) {
+                        // HTTP/2 preface matched
+                        parsingRequestLinePhase = -1;
+                        return false;
+                    }
                 }
                 // Set the start time once we start reading data (even if it is
                 // just skipping blank lines)



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


Mime
View raw message