SLING-2886 Apply Patch by Julian Reschke (thanks alot).

git-svn-id: https://svn.apache.org/repos/asf/sling/trunk@1486579 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/pom.xml b/pom.xml
index 1327e8b..6debfe8 100644
--- a/pom.xml
+++ b/pom.xml
@@ -86,13 +86,13 @@
         <dependency>
             <groupId>org.apache.jackrabbit</groupId>
             <artifactId>jackrabbit-jcr-server</artifactId>
-            <version>2.4.2</version>
+            <version>2.4.4</version>
             <scope>provided</scope>
         </dependency>
         <dependency>
             <groupId>org.apache.jackrabbit</groupId>
             <artifactId>jackrabbit-webdav</artifactId>
-            <version>2.4.2</version>
+            <version>2.4.4</version>
             <scope>provided</scope>
         </dependency>
 
diff --git a/src/main/java/org/apache/sling/jcr/davex/impl/servlets/SlingDavExServlet.java b/src/main/java/org/apache/sling/jcr/davex/impl/servlets/SlingDavExServlet.java
index ec1f85d..ef3319a 100644
--- a/src/main/java/org/apache/sling/jcr/davex/impl/servlets/SlingDavExServlet.java
+++ b/src/main/java/org/apache/sling/jcr/davex/impl/servlets/SlingDavExServlet.java
@@ -71,6 +71,16 @@
     @Property(value=DEFAULT_DAV_ROOT)
     private static final String PROP_DAV_ROOT = "alias";
 
+    private static final boolean DEFAULT_CREATE_ABSOLUTE_URI = true;
+
+    /**
+     * Name of the property to configure whether absolute URIs ({@code true}) or
+     * absolute paths ({@code false}) are generated in responses. Default for
+     * the property is {@link #DEFAULT_CREATE_ABSOLUTE_URI}.
+     */
+    @Property(boolValue=DEFAULT_CREATE_ABSOLUTE_URI)
+    private static final String PROP_CREATE_ABSOLUTE_URI = "dav.create-absolute-uri";
+
     /**
      * The name of the service property of the registered dummy service to cause
      * the path to the DavEx servlet to not be subject to forced authentication.
@@ -110,6 +120,7 @@
     @Activate
     protected void activate(final BundleContext bundleContext, final Map<String, ?> config) {
         final String davRoot = OsgiUtil.toString(config.get(PROP_DAV_ROOT), DEFAULT_DAV_ROOT);
+        final boolean createAbsoluteUri = OsgiUtil.toBoolean(config.get(PROP_CREATE_ABSOLUTE_URI), DEFAULT_CREATE_ABSOLUTE_URI);
 
         final AuthHttpContext context = new AuthHttpContext(davRoot);
         context.setAuthenticationSupport(authSupport);
@@ -120,6 +131,9 @@
         // prefix to the servlet
         initProps.put(INIT_PARAM_RESOURCE_PATH_PREFIX, davRoot);
 
+        // create absolute URIs (or absolute paths)
+        initProps.put(INIT_PARAM_CREATE_ABSOLUTE_URI, Boolean.toString(createAbsoluteUri));
+
         // disable CSRF checks for now (should be handled by Sling)
         initProps.put(INIT_PARAM_CSRF_PROTECTION, CSRFUtil.DISABLED);
 
diff --git a/src/main/resources/OSGI-INF/metatype/metatype.properties b/src/main/resources/OSGI-INF/metatype/metatype.properties
index 1eee1cd..40ba4aa 100644
--- a/src/main/resources/OSGI-INF/metatype/metatype.properties
+++ b/src/main/resources/OSGI-INF/metatype/metatype.properties
@@ -33,6 +33,10 @@
  requests to this servlet do not pass by the Sling Main Servlet and request \
  processing.
 
+dav.create-absolute-uri.name = Use absolute URIs
+dav.create-absolute-uri.description = When set to true, create absolute URIs \
+ in WebDAV responses. Otherwise, use absolute paths. (See RFC 4918, Section 8.3)
+
 alias.name = Root Path
 alias.description = The root path at which the DavEx Servlet is \
  accessible. The default value is "/server".