You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by ma...@apache.org on 2018/09/13 13:44:17 UTC

svn commit: r1840817 - /tomcat/trunk/java/org/apache/catalina/servlets/CGIServlet.java

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