If a resource cannot be deleted by the DefaultServlet https://github.com/apache/tomcat/blob/c50b8aa2588c85df86c0c6e0cd03e79700822360/java/org/apache/catalina/servlets/DefaultServlet.java#L699-L700 METHOD_NOT_ALLOWED is returned. Either the resource is readOnly or java.io.File#delete() returns false. Reasonable. But the WebdavServlet says https://github.com/apache/tomcat/blob/c50b8aa2588c85df86c0c6e0cd03e79700822360/java/org/apache/catalina/servlets/WebdavServlet.java#L1703-L1714 INTERNAL_SERVER_ERROR which is inconsistent and not necessarily true. We can only return this if we use Files#delete(Path). If no one objects I will return METHOD_NOT_ALLOWED for both servlets. Took me some time to search for the exception in the catalina.out which I haven't found until I have found this inconsistency.
Moreover, I'd even use the method sendNotAllowed() for consistency reasons.
(In reply to Michael Osipov from comment #1) > Moreover, I'd even use the method sendNotAllowed() for consistency reasons. Nope, won't work because when a collection is hit it could be partially deleted. I will stick to the status code for now. This change must be reviewed separately.
METHOD_NOT_ALLOWED is not a bad status to return for WebDAV DELETE if it fails, although 500 is ok as well since the cause is not really known.
(In reply to Remy Maucherat from comment #3) > METHOD_NOT_ALLOWED is not a bad status to return for WebDAV DELETE if it > fails, although 500 is ok as well since the cause is not really known. Well, for read-only it is false. The likelyhood for FS failures is smaller here, I guess. Are you OK with METHOD_NOT_ALLOWED consistency for both servlet?
(In reply to Michael Osipov from comment #4) > (In reply to Remy Maucherat from comment #3) > > METHOD_NOT_ALLOWED is not a bad status to return for WebDAV DELETE if it > > fails, although 500 is ok as well since the cause is not really known. > > Well, for read-only it is false. The likelyhood for FS failures is smaller > here, I guess. Are you OK with METHOD_NOT_ALLOWED consistency for both > servlet? Yes, as I was saying, I verified in some docs that METHOD_NOT_ALLOWED is a good return status code in that situation for WebDAV DELETE.
(In reply to Remy Maucherat from comment #5) > (In reply to Michael Osipov from comment #4) > > (In reply to Remy Maucherat from comment #3) > > > METHOD_NOT_ALLOWED is not a bad status to return for WebDAV DELETE if it > > > fails, although 500 is ok as well since the cause is not really known. > > > > Well, for read-only it is false. The likelyhood for FS failures is smaller > > here, I guess. Are you OK with METHOD_NOT_ALLOWED consistency for both > > servlet? > > Yes, as I was saying, I verified in some docs that METHOD_NOT_ALLOWED is a > good return status code in that situation for WebDAV DELETE. Alright, thanks.
Fixed in: - main for 12.0.0-M1 and onwards - 11.0.x for 11.0.0 and onwards - 10.1.x for 10.1.31 and onwards - 9.0.x for 9.0.96 and onwards
Incorporated Mark's objection.