tomcat-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ma...@apache.org
Subject svn commit: r1840817 - /tomcat/trunk/java/org/apache/catalina/servlets/CGIServlet.java
Date Thu, 13 Sep 2018 13:44:17 GMT
Author: markt
Date: Thu Sep 13 13:44:17 2018
New Revision: 1840817

URL: http://svn.apache.org/viewvc?rev=1840817&view=rev
Log:
Improve handling of OPTIONS request

Modified:
    tomcat/trunk/java/org/apache/catalina/servlets/CGIServlet.java

Modified: tomcat/trunk/java/org/apache/catalina/servlets/CGIServlet.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/catalina/servlets/CGIServlet.java?rev=1840817&r1=1840816&r2=1840817&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/catalina/servlets/CGIServlet.java (original)
+++ tomcat/trunk/java/org/apache/catalina/servlets/CGIServlet.java Thu Sep 13 13:44:17 2018
@@ -588,6 +588,29 @@ public final class CGIServlet extends Ht
     }
 
 
+    @Override
+    protected void doOptions(HttpServletRequest req, HttpServletResponse res)
+            throws ServletException, IOException {
+        // Note: This method will never be called if cgiMethods is "*" so that
+        //       case does nto need to be handled here.
+        Set<String> allowedMethods = new HashSet<>();
+        allowedMethods.addAll(cgiMethods);
+        allowedMethods.addAll(CGIServlet.DEFAULT_SUPER_METHODS);
+
+        StringBuilder headerValue = new StringBuilder();
+
+        for (String method : allowedMethods) {
+            headerValue.append(method);
+            headerValue.append(',');
+        }
+
+        // Remove trailing comma
+        headerValue.deleteCharAt(headerValue.length() - 1);
+
+        res.setHeader("allow", headerValue.toString());
+    }
+
+
     /**
      * Behaviour depends on the status code.
      *



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


Mime
View raw message