From 25d3c0d93190ef165ecd6c744bc15b5059abfa8f Mon Sep 17 00:00:00 2001 From: Mark Thomas Date: Tue, 2 May 2017 13:16:08 +0000 Subject: [PATCH] Ensure that when the Default or WebDAV servlets process an error dispatch that the error resource is processed via the doGet() method irrespective of the method used for the original request that triggered the error. git-svn-id: https://svn.apache.org/repos/asf/tomcat/tc8.0.x/trunk@1793489 13f79535-47bb-0310-9956-ffa450edef68 --- .../org/apache/catalina/servlets/DefaultServlet.java | 12 ++++++++++++ java/org/apache/catalina/servlets/WebdavServlet.java | 6 ++++++ webapps/docs/changelog.xml | 6 ++++++ 3 files changed, 24 insertions(+) diff --git a/java/org/apache/catalina/servlets/DefaultServlet.java b/java/org/apache/catalina/servlets/DefaultServlet.java index ec511800a..e40b62859 100644 --- a/java/org/apache/catalina/servlets/DefaultServlet.java +++ b/java/org/apache/catalina/servlets/DefaultServlet.java @@ -380,6 +380,18 @@ protected String getPathPrefix(final HttpServletRequest request) { } + @Override + protected void service(HttpServletRequest req, HttpServletResponse resp) + throws ServletException, IOException { + + if (req.getDispatcherType() == DispatcherType.ERROR) { + doGet(req, resp); + } else { + super.service(req, resp); + } + } + + /** * Process a GET request for the specified resource. * diff --git a/java/org/apache/catalina/servlets/WebdavServlet.java b/java/org/apache/catalina/servlets/WebdavServlet.java index 9fc9ff9ef..5e5f7eb2e 100644 --- a/java/org/apache/catalina/servlets/WebdavServlet.java +++ b/java/org/apache/catalina/servlets/WebdavServlet.java @@ -30,6 +30,7 @@ import java.util.TimeZone; import java.util.Vector; +import javax.servlet.DispatcherType; import javax.servlet.RequestDispatcher; import javax.servlet.ServletContext; import javax.servlet.ServletException; @@ -312,6 +313,11 @@ protected void service(HttpServletRequest req, HttpServletResponse resp) return; } + if (req.getDispatcherType() == DispatcherType.ERROR) { + doGet(req, resp); + return; + } + final String method = req.getMethod(); if (debug > 0) { diff --git a/webapps/docs/changelog.xml b/webapps/docs/changelog.xml index be003aa74..cab4b06dd 100644 --- a/webapps/docs/changelog.xml +++ b/webapps/docs/changelog.xml @@ -78,6 +78,12 @@ determining if the current request is for custom error page or not. (markt) + + Ensure that when the Default or WebDAV servlets process an error + dispatch that the error resource is processed via the + doGet() method irrespective of the method used for the + original request that triggered the error. (markt) +