Bug 64386 - WebdavServlet does not send "getlastmodified" property for resource collections
Summary: WebdavServlet does not send "getlastmodified" property for resource collections
Alias: None
Product: Tomcat 10
Classification: Unclassified
Component: Catalina (show other bugs)
Version: 10.0.0-M4
Hardware: All All
: P2 enhancement (vote)
Target Milestone: ------
Assignee: Tomcat Developers Mailing List
Depends on:
Reported: 2020-04-28 22:10 UTC by Michael Osipov
Modified: 2020-04-29 09:19 UTC (History)
0 users


Note You need to log in before you can comment on or make changes to this bug.
Description Michael Osipov 2020-04-28 22:10:26 UTC
The property is only set for resources (files), not for resource collections (directories) for no reason. Various DAV clients show weird values like 1899-01-01 or something else.

A simple patch makes it work:
diff --git a/java/org/apache/catalina/servlets/WebdavServlet.java b/java/org/apache/catalina/servlets/WebdavServlet.java
index 371de111c9..228bab0032 100644
--- a/java/org/apache/catalina/servlets/WebdavServlet.java
+++ b/java/org/apache/catalina/servlets/WebdavServlet.java
@@ -2087,6 +2082,8 @@ public class WebdavServlet extends DefaultServlet {
                     generatedXML.writeElement("D", "resourcetype", XMLWriter.NO_CONTENT);
             } else {
+                generatedXML.writeProperty("D", "getlastmodified",
+                        FastHttpDateFormat.formatDate(lastModified));
                 generatedXML.writeElement("D", "resourcetype", XMLWriter.OPENING);
                 generatedXML.writeElement("D", "collection", XMLWriter.NO_CONTENT);
                 generatedXML.writeElement("D", "resourcetype", XMLWriter.CLOSING);
Comment 1 Michael Osipov 2020-04-29 09:19:11 UTC
Fixed in:
- master for 10.0.0-M5 and onwards
- 9.0.x  for 9.0.35 and onwards
- 8.5.x for 8.5.55 and onwards
- 7.0.x for 7.0.104 and onwards