This is an automated email from the ASF dual-hosted git repository.

markt pushed a commit to branch 7.0.x
in repository https://gitbox.apache.org/repos/asf/tomcat.git


The following commit(s) were added to refs/heads/7.0.x by this push:
     new 872f0a3  Additional fix for 
https://bz.apache.org/bugzilla/show_bug.cgi?id=63825
872f0a3 is described below

commit 872f0a3ed348520bc521add259ed8a852c33b58e
Author: Mark Thomas <ma...@apache.org>
AuthorDate: Fri Oct 18 22:53:19 2019 +0100

    Additional fix for https://bz.apache.org/bugzilla/show_bug.cgi?id=63825
    
    Local performance testing shows no negative impact and possibly a small
    gain.
---
 .../coyote/http11/AbstractHttp11Processor.java     | 27 ++++++++++++++--------
 java/org/apache/coyote/http11/Constants.java       |  8 +++++++
 2 files changed, 26 insertions(+), 9 deletions(-)

diff --git a/java/org/apache/coyote/http11/AbstractHttp11Processor.java 
b/java/org/apache/coyote/http11/AbstractHttp11Processor.java
index 48c9c93..37ecc9a 100644
--- a/java/org/apache/coyote/http11/AbstractHttp11Processor.java
+++ b/java/org/apache/coyote/http11/AbstractHttp11Processor.java
@@ -19,6 +19,7 @@ package org.apache.coyote.http11;
 import java.io.IOException;
 import java.io.InterruptedIOException;
 import java.io.StringReader;
+import java.util.Collection;
 import java.util.Enumeration;
 import java.util.HashSet;
 import java.util.List;
@@ -693,7 +694,10 @@ public abstract class AbstractHttp11Processor<S> extends 
AbstractProcessor<S> {
     /**
      * Specialized utility method: find a sequence of lower case bytes inside
      * a ByteChunk.
+     *
+     * @deprecated Unused. Will be removed in Tomcat 8.5.x.
      */
+    @Deprecated
     protected int findBytes(ByteChunk bc, byte[] b) {
 
         byte first = b[0];
@@ -1288,7 +1292,7 @@ public abstract class AbstractHttp11Processor<S> extends 
AbstractProcessor<S> {
     /**
      * After reading the request headers, we have to setup the request filters.
      */
-    protected void prepareRequest() {
+    protected void prepareRequest() throws IOException {
 
         http11 = true;
         http09 = false;
@@ -1337,11 +1341,11 @@ public abstract class AbstractHttp11Processor<S> 
extends AbstractProcessor<S> {
         // Check connection header
         MessageBytes connectionValueMB = 
headers.getValue(Constants.CONNECTION);
         if (connectionValueMB != null && !connectionValueMB.isNull()) {
-            ByteChunk connectionValueBC = connectionValueMB.getByteChunk();
-            if (findBytes(connectionValueBC, Constants.CLOSE_BYTES) != -1) {
+            Set<String> tokens = new HashSet<String>();
+            parseConnectionTokens(headers, tokens);
+            if (tokens.contains(Constants.CLOSE)) {
                 keepAlive = false;
-            } else if (findBytes(connectionValueBC,
-                                 Constants.KEEPALIVE_BYTES) != -1) {
+            } else if (tokens.contains(Constants.KEEPALIVE)) {
                 keepAlive = true;
             }
         }
@@ -1746,22 +1750,27 @@ public abstract class AbstractHttp11Processor<S> 
extends AbstractProcessor<S> {
 
     }
 
+
     private static boolean isConnectionToken(MimeHeaders headers, String 
token) throws IOException {
         MessageBytes connection = headers.getValue(Constants.CONNECTION);
         if (connection == null) {
             return false;
         }
 
+        Set<String> tokens = new HashSet<String>();
+        parseConnectionTokens(headers, tokens);
+        return tokens.contains(token);
+    }
+
+
+    private static void parseConnectionTokens(MimeHeaders headers, 
Collection<String> tokens) throws IOException {
         Enumeration<String> values = headers.values(Constants.CONNECTION);
-        Set<String> result = new HashSet<String>();
         while (values.hasMoreElements()) {
             String nextHeaderValue = values.nextElement();
             if (nextHeaderValue != null) {
-                TokenList.parseTokenList(new StringReader(nextHeaderValue), 
result);
+                TokenList.parseTokenList(new StringReader(nextHeaderValue), 
tokens);
             }
         }
-
-        return result.contains(token);
     }
 
 
diff --git a/java/org/apache/coyote/http11/Constants.java 
b/java/org/apache/coyote/http11/Constants.java
index 20362dd..98cfef3 100644
--- a/java/org/apache/coyote/http11/Constants.java
+++ b/java/org/apache/coyote/http11/Constants.java
@@ -123,9 +123,17 @@ public final class Constants {
     /* Various constant "strings" */
     public static final String CONNECTION = "Connection";
     public static final String CLOSE = "close";
+    /**
+     * @deprecated Unused. Will be removed in Tomcat 10.
+     */
+    @Deprecated
     public static final byte[] CLOSE_BYTES =
         ByteChunk.convertToBytes(CLOSE);
     public static final String KEEPALIVE = "keep-alive";
+    /**
+     * @deprecated Unused. Will be removed in Tomcat 10.
+     */
+    @Deprecated
     public static final byte[] KEEPALIVE_BYTES =
         ByteChunk.convertToBytes(KEEPALIVE);
     public static final String CHUNKED = "chunked";


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

Reply via email to