This is an automated email from the ASF dual-hosted git repository. rombert pushed a commit to annotated tag org.apache.sling.jcr.webdav-2.0.8 in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-jcr-webdav.git
commit 060762a7aea68e0ef1da6a770f9692c4b8bc0753 Author: Felix Meschberger <[email protected]> AuthorDate: Tue Dec 1 09:24:23 2009 +0000 SLING-1211 Streamline service method and add support for direct reply to the OPTIONS request on the Dav root. git-svn-id: https://svn.apache.org/repos/asf/sling/trunk/bundles/jcr/webdav@885697 13f79535-47bb-0310-9956-ffa450edef68 --- .../impl/servlets/SlingSimpleWebDavServlet.java | 47 +++++++++++++++------- 1 file changed, 33 insertions(+), 14 deletions(-) diff --git a/src/main/java/org/apache/sling/jcr/webdav/impl/servlets/SlingSimpleWebDavServlet.java b/src/main/java/org/apache/sling/jcr/webdav/impl/servlets/SlingSimpleWebDavServlet.java index 57f5f5a..30e999e 100644 --- a/src/main/java/org/apache/sling/jcr/webdav/impl/servlets/SlingSimpleWebDavServlet.java +++ b/src/main/java/org/apache/sling/jcr/webdav/impl/servlets/SlingSimpleWebDavServlet.java @@ -51,47 +51,66 @@ public class SlingSimpleWebDavServlet extends SimpleWebdavServlet { @Override public void init() throws ServletException { super.init(); - + setResourceConfig(resourceConfig); } - + @Override protected void service(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { + // According to the spec the path info is either null or + // a string starting with a slash. Thus a string of length 1 + // will be a string containing just the slash, which should not + // be handled by the base class final String pinfo = request.getPathInfo(); + if (pinfo != null && pinfo.length() > 1) { + + // regular request, have the SimpleWebDAVServlet handle the request + super.service(request, response); + + } else if ("OPTIONS".equals(request.getMethod())) { - if (pinfo == null || "/".equals(pinfo)) { - // redirect to the default workspace if directly addressing the - // servlet - // and if the default workspace name is not null (in which case we'd - // need - // to login to find out the actual workspace name, SLING-256) + // OPTIONS request on the root, answer with the Allow header + // without DAV-specific headers + response.setContentLength(0); + response.setStatus(HttpServletResponse.SC_OK); + response.setHeader("Allow", "OPTIONS, GET, HEAD"); + + } else { + + // request to the "root", redirect to the default workspace if + // directly addressing the servlet and if the default workspace name + // is not null (in which case we'd need to login to find out the + // actual workspace name, SLING-256) SlingRepository slingRepo = (SlingRepository) getRepository(); if (slingRepo.getDefaultWorkspace() == null) { + + // if we don't have a default workspace to redirect to, we + // cannot handle the request and fail with not found response.sendError( HttpServletResponse.SC_NOT_FOUND, "JCR workspace name required, please add it to the end of the URL" + " (for the Jackrabbit embedded repository the default name is 'default') "); + } else { + + // else redirect to the same URI with the default workspace + // appended String uri = request.getRequestURI(); if (pinfo == null) { uri += "/"; } uri += slingRepo.getDefaultWorkspace(); response.sendRedirect(uri); - } - - } else { - super.service(request, response); + } } - } @Override public Repository getRepository() { return repository; } - + } -- To stop receiving notification emails like this one, please contact "[email protected]" <[email protected]>.
