https://bz.apache.org/bugzilla/show_bug.cgi?id=70380

            Bug ID: 70380
           Summary: Allow header in the 405 response to TRACE does not
                    match the servlet's OPTIONS response
           Product: Tomcat 11
           Version: 11.0.27
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: minor
          Priority: P2
         Component: Catalina
          Assignee: [email protected]
          Reporter: [email protected]
  Target Milestone: -------

With allowTrace="false" the CoyoteAdapter rejects TRACE with a 405 and builds
the Allow header from Wrapper.getServletMethods(). That list does not match the
Allow header the servlet itself returns.

For a static file served by the DefaultServlet with the default configuration,
TRACE returns "Allow: HEAD, DELETE, POST, GET, OPTIONS, PUT", while PUT, DELETE
and POST to the same file return 405 with "Allow: OPTIONS, GET, HEAD". Bug
49286 was closed on the basis that PUT and DELETE returned 403 and that a
method answered with 405 must not be listed in Allow. PUT and DELETE now return
405 when the servlet is read only, but the TRACE response still lists them.

For a servlet that implements doGet and doPatch, OPTIONS returns "Allow: GET,
HEAD, PATCH, OPTIONS" but TRACE returns "Allow: HEAD, GET, OPTIONS". The
reflection in StandardWrapper.getServletMethods() only looks for doGet, doPost,
doPut and doDelete, while HttpServlet also considers doPatch and doQuery.

The Javadoc of Wrapper.getServletMethods() says it returns the same methods as
the Allow header of an OPTIONS response, and similar mismatches were fixed for
JSPs and in bug 60697. Adding doPatch and doQuery to the reflection is
straightforward. Getting the DefaultServlet and WebDAV cases right probably
needs the servlet to supply its own list, which is a design choice, so I have
not prepared a patch for that part. Happy to provide one for whichever approach
is preferred.

-- 
You are receiving this mail because:
You are the assignee for the bug.
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to