tomcat-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ma...@apache.org
Subject svn commit: r1599738 - /tomcat/trunk/java/org/apache/coyote/http11/AbstractHttp11Processor.java
Date Tue, 03 Jun 2014 18:37:01 GMT
Author: markt
Date: Tue Jun  3 18:37:00 2014
New Revision: 1599738

URL: http://svn.apache.org/r1599738
Log:
Reduce duplicate by moving error handling into addInputFilter.
Also makes error handling consistent.
Reduce visibility of addInputFilter()

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

Modified: tomcat/trunk/java/org/apache/coyote/http11/AbstractHttp11Processor.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/coyote/http11/AbstractHttp11Processor.java?rev=1599738&r1=1599737&r2=1599738&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/coyote/http11/AbstractHttp11Processor.java (original)
+++ tomcat/trunk/java/org/apache/coyote/http11/AbstractHttp11Processor.java Tue Jun  3 18:37:00
2014
@@ -674,12 +674,10 @@ public abstract class AbstractHttp11Proc
 
 
     /**
-     * Add an input filter to the current request.
-     *
-     * @return false if the encoding was not found (which would mean it is
-     * unsupported)
+     * Add an input filter to the current request. If the encoding is not
+     * supported, a 501 response will be returned to the client.
      */
-    protected boolean addInputFilter(InputFilter[] inputFilters,
+    private void addInputFilter(InputFilter[] inputFilters,
                                      String encodingName) {
         if (encodingName.equals("identity")) {
             // Skip
@@ -689,15 +687,20 @@ public abstract class AbstractHttp11Proc
             contentDelimitation = true;
         } else {
             for (int i = pluggableFilterIndex; i < inputFilters.length; i++) {
-                if (inputFilters[i].getEncodingName()
-                    .toString().equals(encodingName)) {
+                if (inputFilters[i].getEncodingName().toString().equals(encodingName)) {
                     getInputBuffer().addActiveFilter(inputFilters[i]);
-                    return true;
+                    return;
                 }
             }
-            return false;
+            // Unsupported transfer encoding
+            // 501 - Unimplemented
+            response.setStatus(501);
+            error = true;
+            if (getLog().isDebugEnabled()) {
+                getLog().debug(sm.getString("http11processor.request.prepare") +
+                          " Unsupported transfer encoding [" + encodingName + "]");
+            }
         }
-        return true;
     }
 
 
@@ -1317,29 +1320,15 @@ public abstract class AbstractHttp11Proc
             int commaPos = transferEncodingValue.indexOf(',');
             String encodingName = null;
             while (commaPos != -1) {
-                encodingName = transferEncodingValue.substring
-                    (startPos, commaPos).toLowerCase(Locale.ENGLISH).trim();
-                if (!addInputFilter(inputFilters, encodingName)) {
-                    // Unsupported transfer encoding
-                    error = true;
-                    // 501 - Unimplemented
-                    response.setStatus(501);
-                }
+                encodingName = transferEncodingValue.substring(
+                        startPos, commaPos).toLowerCase(Locale.ENGLISH).trim();
+                addInputFilter(inputFilters, encodingName);
                 startPos = commaPos + 1;
                 commaPos = transferEncodingValue.indexOf(',', startPos);
             }
-            encodingName = transferEncodingValue.substring(startPos)
-                .toLowerCase(Locale.ENGLISH).trim();
-            if (!addInputFilter(inputFilters, encodingName)) {
-                // Unsupported transfer encoding
-                error = true;
-                // 501 - Unimplemented
-                if (getLog().isDebugEnabled()) {
-                    getLog().debug(sm.getString("http11processor.request.prepare")+
-                              " Unsupported transfer encoding \""+encodingName+"\"");
-                }
-                response.setStatus(501);
-            }
+            encodingName = transferEncodingValue.substring(
+                    startPos).toLowerCase(Locale.ENGLISH).trim();
+            addInputFilter(inputFilters, encodingName);
         }
 
         // Parse content-length header



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


Mime
View raw message