Re: (tomcat) branch main updated: Add option to serve resources from subpath only with WebDAV Servlet

2024-11-13 Thread Mark Thomas

On 13/11/2024 11:10, micha...@apache.org wrote:

This is an automated email from the ASF dual-hosted git repository.

michaelo pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/tomcat.git


The following commit(s) were added to refs/heads/main by this push:
  new f5601ff240 Add option to serve resources from subpath only with 
WebDAV Servlet
f5601ff240 is described below

commit f5601ff240e2c7f8cb98fe79e8e30f53b731edfd
Author: Michael Osipov 
AuthorDate: Wed Nov 13 11:48:00 2024 +0100

 Add option to serve resources from subpath only with WebDAV Servlet


What is the use case for this?

Mark

-
To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org
For additional commands, e-mail: dev-h...@tomcat.apache.org



Re: (tomcat) branch main updated: Add option to serve resources from subpath only with WebDAV Servlet

2024-11-13 Thread Michael Osipov
On 2024/11/13 12:33:20 Mark Thomas wrote:
> On 13/11/2024 11:10, micha...@apache.org wrote:
> > This is an automated email from the ASF dual-hosted git repository.
> > 
> > michaelo pushed a commit to branch main
> > in repository https://gitbox.apache.org/repos/asf/tomcat.git
> > 
> > 
> > The following commit(s) were added to refs/heads/main by this push:
> >   new f5601ff240 Add option to serve resources from subpath only with 
> > WebDAV Servlet
> > f5601ff240 is described below
> > 
> > commit f5601ff240e2c7f8cb98fe79e8e30f53b731edfd
> > Author: Michael Osipov 
> > AuthorDate: Wed Nov 13 11:48:00 2024 +0100
> > 
> >  Add option to serve resources from subpath only with WebDAV Servlet
> 
> What is the use case for this?

Simple. Serving a subset of mounted resources just like mod_dav (replacement) 
would w/o exposing the entire webapp resources, e.g.:




webdav
/dav/*


Basically the same as DefaultServlet, but with DAV capabilites.

-
To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org
For additional commands, e-mail: dev-h...@tomcat.apache.org



(tomcat) branch main updated: Add option to serve resources from subpath only with WebDAV Servlet

2024-11-13 Thread michaelo
This is an automated email from the ASF dual-hosted git repository.

michaelo pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/tomcat.git


The following commit(s) were added to refs/heads/main by this push:
 new f5601ff240 Add option to serve resources from subpath only with WebDAV 
Servlet
f5601ff240 is described below

commit f5601ff240e2c7f8cb98fe79e8e30f53b731edfd
Author: Michael Osipov 
AuthorDate: Wed Nov 13 11:48:00 2024 +0100

Add option to serve resources from subpath only with WebDAV Servlet
---
 .../apache/catalina/servlets/WebdavServlet.java| 23 --
 webapps/docs/changelog.xml |  4 
 2 files changed, 25 insertions(+), 2 deletions(-)

diff --git a/java/org/apache/catalina/servlets/WebdavServlet.java 
b/java/org/apache/catalina/servlets/WebdavServlet.java
index 0766e91b84..8de9008314 100644
--- a/java/org/apache/catalina/servlets/WebdavServlet.java
+++ b/java/org/apache/catalina/servlets/WebdavServlet.java
@@ -74,11 +74,12 @@ import org.xml.sax.SAXException;
 /**
  * Servlet which adds support for https://tools.ietf.org/html/rfc4918";>WebDAV
  * https://tools.ietf.org/html/rfc4918#section-18";>level 3. All 
the basic HTTP requests are handled by the
- * DefaultServlet. The WebDAVServlet must not be used as the default servlet 
(ie mapped to '/') as it will not work in
+ * DefaultServlet. The WebdavServlet must not be used as the default servlet 
(ie mapped to '/') as it will not work in
  * this configuration.
  * 
  * Mapping a subpath (e.g. /webdav/* to this servlet has the 
effect of re-mounting the entire web
- * application under that sub-path, with WebDAV access to all the resources. 
The WEB-INF and
+ * application under that sub-path, with WebDAV access to all the resources. 
To restore the DefaultServlet
+ * behavior set serveSubpathOnly to true. The 
WEB-INF and
  * META-INF directories are protected in this re-mounted resource 
tree.
  * 
  * To enable WebDAV for a context add the following to web.xml:
@@ -247,6 +248,12 @@ public class WebdavServlet extends DefaultServlet 
implements PeriodicEventListen
  */
 private boolean strictIfProcessing = true;
 
+/**
+ * Serve resources from the mounted subpath only, restoring the behavior of
+ * {@code DefaultServlet}.
+ */
+private boolean serveSubpathOnly = false;
+
 
 /**
  * Property store used for storage of dead properties.
@@ -285,6 +292,10 @@ public class WebdavServlet extends DefaultServlet 
implements PeriodicEventListen
 strictIfProcessing = 
Boolean.parseBoolean(getServletConfig().getInitParameter("strictIfProcessing"));
 }
 
+if (getServletConfig().getInitParameter("serveSubpathOnly") != null) {
+serveSubpathOnly = 
Boolean.parseBoolean(getServletConfig().getInitParameter("serveSubpathOnly"));
+}
+
 String propertyStore = 
getServletConfig().getInitParameter("propertyStore");
 if (propertyStore != null) {
 try {
@@ -686,6 +697,10 @@ public class WebdavServlet extends DefaultServlet 
implements PeriodicEventListen
  */
 @Override
 protected String getRelativePath(HttpServletRequest request, boolean 
allowEmptyPath) {
+if (serveSubpathOnly) {
+return super.getRelativePath(request, allowEmptyPath);
+}
+
 String pathInfo;
 
 if (request.getAttribute(RequestDispatcher.INCLUDE_REQUEST_URI) != 
null) {
@@ -712,6 +727,10 @@ public class WebdavServlet extends DefaultServlet 
implements PeriodicEventListen
 
 @Override
 protected String getPathPrefix(final HttpServletRequest request) {
+if (serveSubpathOnly) {
+return super.getPathPrefix(request);
+}
+
 // Repeat the servlet path (e.g. /webdav/) in the listing path
 String contextPath = request.getContextPath();
 if (request.getServletPath() != null) {
diff --git a/webapps/docs/changelog.xml b/webapps/docs/changelog.xml
index 56b87edce9..0fe94c3a63 100644
--- a/webapps/docs/changelog.xml
+++ b/webapps/docs/changelog.xml
@@ -126,6 +126,10 @@
 Remove default value (was catalina) for the
 secret init parameter of the WebDAV Servlet. (remm)
   
+  
+Add option to serve resources from subpath only with WebDAV Servlet 
like
+with DefaultServlet. (michaelo)
+  
   
 
   


-
To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org
For additional commands, e-mail: dev-h...@tomcat.apache.org



(tomcat) branch 10.1.x updated: Add option to serve resources from subpath only with WebDAV Servlet

2024-11-13 Thread michaelo
This is an automated email from the ASF dual-hosted git repository.

michaelo pushed a commit to branch 10.1.x
in repository https://gitbox.apache.org/repos/asf/tomcat.git


The following commit(s) were added to refs/heads/10.1.x by this push:
 new b70cdd45de Add option to serve resources from subpath only with WebDAV 
Servlet
b70cdd45de is described below

commit b70cdd45deb1ec4220a62d49d71ae306a8d96bfa
Author: Michael Osipov 
AuthorDate: Wed Nov 13 11:48:00 2024 +0100

Add option to serve resources from subpath only with WebDAV Servlet
---
 .../apache/catalina/servlets/WebdavServlet.java| 23 --
 webapps/docs/changelog.xml |  8 
 2 files changed, 29 insertions(+), 2 deletions(-)

diff --git a/java/org/apache/catalina/servlets/WebdavServlet.java 
b/java/org/apache/catalina/servlets/WebdavServlet.java
index c8f81c7efc..e56c2842bf 100644
--- a/java/org/apache/catalina/servlets/WebdavServlet.java
+++ b/java/org/apache/catalina/servlets/WebdavServlet.java
@@ -74,11 +74,12 @@ import org.xml.sax.SAXException;
 /**
  * Servlet which adds support for https://tools.ietf.org/html/rfc4918";>WebDAV
  * https://tools.ietf.org/html/rfc4918#section-18";>level 3. All 
the basic HTTP requests are handled by the
- * DefaultServlet. The WebDAVServlet must not be used as the default servlet 
(ie mapped to '/') as it will not work in
+ * DefaultServlet. The WebdavServlet must not be used as the default servlet 
(ie mapped to '/') as it will not work in
  * this configuration.
  * 
  * Mapping a subpath (e.g. /webdav/* to this servlet has the 
effect of re-mounting the entire web
- * application under that sub-path, with WebDAV access to all the resources. 
The WEB-INF and
+ * application under that sub-path, with WebDAV access to all the resources. 
To restore the DefaultServlet
+ * behavior set serveSubpathOnly to true. The 
WEB-INF and
  * META-INF directories are protected in this re-mounted resource 
tree.
  * 
  * To enable WebDAV for a context add the following to web.xml:
@@ -247,6 +248,12 @@ public class WebdavServlet extends DefaultServlet 
implements PeriodicEventListen
  */
 private boolean strictIfProcessing = true;
 
+/**
+ * Serve resources from the mounted subpath only, restoring the behavior of
+ * {@code DefaultServlet}.
+ */
+private boolean serveSubpathOnly = false;
+
 
 /**
  * Property store used for storage of dead properties.
@@ -285,6 +292,10 @@ public class WebdavServlet extends DefaultServlet 
implements PeriodicEventListen
 strictIfProcessing = 
Boolean.parseBoolean(getServletConfig().getInitParameter("strictIfProcessing"));
 }
 
+if (getServletConfig().getInitParameter("serveSubpathOnly") != null) {
+serveSubpathOnly = 
Boolean.parseBoolean(getServletConfig().getInitParameter("serveSubpathOnly"));
+}
+
 String propertyStore = 
getServletConfig().getInitParameter("propertyStore");
 if (propertyStore != null) {
 try {
@@ -686,6 +697,10 @@ public class WebdavServlet extends DefaultServlet 
implements PeriodicEventListen
  */
 @Override
 protected String getRelativePath(HttpServletRequest request, boolean 
allowEmptyPath) {
+if (serveSubpathOnly) {
+return super.getRelativePath(request, allowEmptyPath);
+}
+
 String pathInfo;
 
 if (request.getAttribute(RequestDispatcher.INCLUDE_REQUEST_URI) != 
null) {
@@ -712,6 +727,10 @@ public class WebdavServlet extends DefaultServlet 
implements PeriodicEventListen
 
 @Override
 protected String getPathPrefix(final HttpServletRequest request) {
+if (serveSubpathOnly) {
+return super.getPathPrefix(request);
+}
+
 // Repeat the servlet path (e.g. /webdav/) in the listing path
 String contextPath = request.getContextPath();
 if (request.getServletPath() != null) {
diff --git a/webapps/docs/changelog.xml b/webapps/docs/changelog.xml
index edcd17a90b..53731feae2 100644
--- a/webapps/docs/changelog.xml
+++ b/webapps/docs/changelog.xml
@@ -105,6 +105,14 @@
   issues do not "pop up" wrt. others).
 -->
 
+  
+
+  
+Add option to serve resources from subpath only with WebDAV Servlet 
like
+with DefaultServlet. (michaelo)
+  
+
+  
   
 
   


-
To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org
For additional commands, e-mail: dev-h...@tomcat.apache.org



(tomcat) branch 11.0.x updated: Add option to serve resources from subpath only with WebDAV Servlet

2024-11-13 Thread michaelo
This is an automated email from the ASF dual-hosted git repository.

michaelo pushed a commit to branch 11.0.x
in repository https://gitbox.apache.org/repos/asf/tomcat.git


The following commit(s) were added to refs/heads/11.0.x by this push:
 new a4259bcaf2 Add option to serve resources from subpath only with WebDAV 
Servlet
a4259bcaf2 is described below

commit a4259bcaf2a6461c358e5b77746482aefeba1178
Author: Michael Osipov 
AuthorDate: Wed Nov 13 11:48:00 2024 +0100

Add option to serve resources from subpath only with WebDAV Servlet
---
 .../apache/catalina/servlets/WebdavServlet.java| 23 --
 webapps/docs/changelog.xml |  8 
 2 files changed, 29 insertions(+), 2 deletions(-)

diff --git a/java/org/apache/catalina/servlets/WebdavServlet.java 
b/java/org/apache/catalina/servlets/WebdavServlet.java
index 0766e91b84..8de9008314 100644
--- a/java/org/apache/catalina/servlets/WebdavServlet.java
+++ b/java/org/apache/catalina/servlets/WebdavServlet.java
@@ -74,11 +74,12 @@ import org.xml.sax.SAXException;
 /**
  * Servlet which adds support for https://tools.ietf.org/html/rfc4918";>WebDAV
  * https://tools.ietf.org/html/rfc4918#section-18";>level 3. All 
the basic HTTP requests are handled by the
- * DefaultServlet. The WebDAVServlet must not be used as the default servlet 
(ie mapped to '/') as it will not work in
+ * DefaultServlet. The WebdavServlet must not be used as the default servlet 
(ie mapped to '/') as it will not work in
  * this configuration.
  * 
  * Mapping a subpath (e.g. /webdav/* to this servlet has the 
effect of re-mounting the entire web
- * application under that sub-path, with WebDAV access to all the resources. 
The WEB-INF and
+ * application under that sub-path, with WebDAV access to all the resources. 
To restore the DefaultServlet
+ * behavior set serveSubpathOnly to true. The 
WEB-INF and
  * META-INF directories are protected in this re-mounted resource 
tree.
  * 
  * To enable WebDAV for a context add the following to web.xml:
@@ -247,6 +248,12 @@ public class WebdavServlet extends DefaultServlet 
implements PeriodicEventListen
  */
 private boolean strictIfProcessing = true;
 
+/**
+ * Serve resources from the mounted subpath only, restoring the behavior of
+ * {@code DefaultServlet}.
+ */
+private boolean serveSubpathOnly = false;
+
 
 /**
  * Property store used for storage of dead properties.
@@ -285,6 +292,10 @@ public class WebdavServlet extends DefaultServlet 
implements PeriodicEventListen
 strictIfProcessing = 
Boolean.parseBoolean(getServletConfig().getInitParameter("strictIfProcessing"));
 }
 
+if (getServletConfig().getInitParameter("serveSubpathOnly") != null) {
+serveSubpathOnly = 
Boolean.parseBoolean(getServletConfig().getInitParameter("serveSubpathOnly"));
+}
+
 String propertyStore = 
getServletConfig().getInitParameter("propertyStore");
 if (propertyStore != null) {
 try {
@@ -686,6 +697,10 @@ public class WebdavServlet extends DefaultServlet 
implements PeriodicEventListen
  */
 @Override
 protected String getRelativePath(HttpServletRequest request, boolean 
allowEmptyPath) {
+if (serveSubpathOnly) {
+return super.getRelativePath(request, allowEmptyPath);
+}
+
 String pathInfo;
 
 if (request.getAttribute(RequestDispatcher.INCLUDE_REQUEST_URI) != 
null) {
@@ -712,6 +727,10 @@ public class WebdavServlet extends DefaultServlet 
implements PeriodicEventListen
 
 @Override
 protected String getPathPrefix(final HttpServletRequest request) {
+if (serveSubpathOnly) {
+return super.getPathPrefix(request);
+}
+
 // Repeat the servlet path (e.g. /webdav/) in the listing path
 String contextPath = request.getContextPath();
 if (request.getServletPath() != null) {
diff --git a/webapps/docs/changelog.xml b/webapps/docs/changelog.xml
index 3258e25c76..1bc004509c 100644
--- a/webapps/docs/changelog.xml
+++ b/webapps/docs/changelog.xml
@@ -105,6 +105,14 @@
   issues do not "pop up" wrt. others).
 -->
 
+  
+
+  
+Add option to serve resources from subpath only with WebDAV Servlet 
like
+with DefaultServlet. (michaelo)
+  
+
+  
   
 
   


-
To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org
For additional commands, e-mail: dev-h...@tomcat.apache.org



(tomcat) branch 9.0.x updated: Add option to serve resources from subpath only with WebDAV Servlet

2024-11-13 Thread michaelo
This is an automated email from the ASF dual-hosted git repository.

michaelo pushed a commit to branch 9.0.x
in repository https://gitbox.apache.org/repos/asf/tomcat.git


The following commit(s) were added to refs/heads/9.0.x by this push:
 new 35dc268d4d Add option to serve resources from subpath only with WebDAV 
Servlet
35dc268d4d is described below

commit 35dc268d4dd3460b3e2d4952c9280a760c23bbc2
Author: Michael Osipov 
AuthorDate: Wed Nov 13 11:48:00 2024 +0100

Add option to serve resources from subpath only with WebDAV Servlet
---
 .../apache/catalina/servlets/WebdavServlet.java| 23 --
 webapps/docs/changelog.xml |  8 
 2 files changed, 29 insertions(+), 2 deletions(-)

diff --git a/java/org/apache/catalina/servlets/WebdavServlet.java 
b/java/org/apache/catalina/servlets/WebdavServlet.java
index 916bd058fc..c8d82b4a7a 100644
--- a/java/org/apache/catalina/servlets/WebdavServlet.java
+++ b/java/org/apache/catalina/servlets/WebdavServlet.java
@@ -73,11 +73,12 @@ import org.xml.sax.SAXException;
 /**
  * Servlet which adds support for https://tools.ietf.org/html/rfc4918";>WebDAV
  * https://tools.ietf.org/html/rfc4918#section-18";>level 3. All 
the basic HTTP requests are handled by the
- * DefaultServlet. The WebDAVServlet must not be used as the default servlet 
(ie mapped to '/') as it will not work in
+ * DefaultServlet. The WebdavServlet must not be used as the default servlet 
(ie mapped to '/') as it will not work in
  * this configuration.
  * 
  * Mapping a subpath (e.g. /webdav/* to this servlet has the 
effect of re-mounting the entire web
- * application under that sub-path, with WebDAV access to all the resources. 
The WEB-INF and
+ * application under that sub-path, with WebDAV access to all the resources. 
To restore the DefaultServlet
+ * behavior set serveSubpathOnly to true. The 
WEB-INF and
  * META-INF directories are protected in this re-mounted resource 
tree.
  * 
  * To enable WebDAV for a context add the following to web.xml:
@@ -246,6 +247,12 @@ public class WebdavServlet extends DefaultServlet 
implements PeriodicEventListen
  */
 private boolean strictIfProcessing = true;
 
+/**
+ * Serve resources from the mounted subpath only, restoring the behavior of
+ * {@code DefaultServlet}.
+ */
+private boolean serveSubpathOnly = false;
+
 
 /**
  * Property store used for storage of dead properties.
@@ -284,6 +291,10 @@ public class WebdavServlet extends DefaultServlet 
implements PeriodicEventListen
 strictIfProcessing = 
Boolean.parseBoolean(getServletConfig().getInitParameter("strictIfProcessing"));
 }
 
+if (getServletConfig().getInitParameter("serveSubpathOnly") != null) {
+serveSubpathOnly = 
Boolean.parseBoolean(getServletConfig().getInitParameter("serveSubpathOnly"));
+}
+
 String propertyStore = 
getServletConfig().getInitParameter("propertyStore");
 if (propertyStore != null) {
 try {
@@ -685,6 +696,10 @@ public class WebdavServlet extends DefaultServlet 
implements PeriodicEventListen
  */
 @Override
 protected String getRelativePath(HttpServletRequest request, boolean 
allowEmptyPath) {
+if (serveSubpathOnly) {
+return super.getRelativePath(request, allowEmptyPath);
+}
+
 String pathInfo;
 
 if (request.getAttribute(RequestDispatcher.INCLUDE_REQUEST_URI) != 
null) {
@@ -711,6 +726,10 @@ public class WebdavServlet extends DefaultServlet 
implements PeriodicEventListen
 
 @Override
 protected String getPathPrefix(final HttpServletRequest request) {
+if (serveSubpathOnly) {
+return super.getPathPrefix(request);
+}
+
 // Repeat the servlet path (e.g. /webdav/) in the listing path
 String contextPath = request.getContextPath();
 if (request.getServletPath() != null) {
diff --git a/webapps/docs/changelog.xml b/webapps/docs/changelog.xml
index dd4e29000a..921b590ddc 100644
--- a/webapps/docs/changelog.xml
+++ b/webapps/docs/changelog.xml
@@ -105,6 +105,14 @@
   issues do not "pop up" wrt. others).
 -->
 
+  
+
+  
+Add option to serve resources from subpath only with WebDAV Servlet 
like
+with DefaultServlet. (michaelo)
+  
+
+  
   
 
   


-
To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org
For additional commands, e-mail: dev-h...@tomcat.apache.org