### Eclipse Workspace Patch 1.0 #P jackrabbit-webdav Index: src/main/java/org/apache/jackrabbit/webdav/server/AbstractWebdavServlet.java =================================================================== --- src/main/java/org/apache/jackrabbit/webdav/server/AbstractWebdavServlet.java (revision 1241895) +++ src/main/java/org/apache/jackrabbit/webdav/server/AbstractWebdavServlet.java (working copy) @@ -134,7 +134,14 @@ */ public static final String INIT_PARAM_CSRF_PROTECTION = "csrf-protection"; + /** + * Name of the 'createAbsoluteURI' init parameter that defines whether hrefs + * should be created with a absolute URI or as absolute Path (ContextPath). + * The value should be 'true' or 'false'. The default value if not set is true. + */ + public final static String INIT_PARAM_CREATE_ABSOLUTE_URI = "createAbsoluteURI"; + /** * Header value as specified in the {@link #INIT_PARAM_AUTHENTICATE_HEADER} parameter. */ @@ -145,6 +152,11 @@ */ private CSRFUtil csrfUtil; + /** + * Create per default absolute URI hrefs + */ + private boolean createAbsoluteURI = true; + @Override public void init() throws ServletException { super.init(); @@ -160,6 +172,10 @@ String csrfParam = getInitParameter(INIT_PARAM_CSRF_PROTECTION); csrfUtil = new CSRFUtil(csrfParam); log.info(INIT_PARAM_CSRF_PROTECTION + " = " + csrfParam); + + //create absolute URI hrefs.. + createAbsoluteURI = Boolean.parseBoolean(getInitParameter(INIT_PARAM_CREATE_ABSOLUTE_URI)); + log.info(INIT_PARAM_CREATE_ABSOLUTE_URI + " = " + createAbsoluteURI); } /** @@ -226,6 +242,15 @@ } /** + * Returns if a absolute URI should be created for hrefs. + * + * @return absolute URI hrefs + */ + protected boolean isCreateAbsoluteURI() { + return createAbsoluteURI; + } + + /** * Service the given request. * * @param request @@ -237,7 +262,7 @@ protected void service(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { - WebdavRequest webdavRequest = new WebdavRequestImpl(request, getLocatorFactory()); + WebdavRequest webdavRequest = new WebdavRequestImpl(request, getLocatorFactory(), isCreateAbsoluteURI()); // DeltaV requires 'Cache-Control' header for all methods except 'VERSION-CONTROL' and 'REPORT'. int methodCode = DavMethods.getMethodCode(request.getMethod()); boolean noCache = DavMethods.isDeltaVMethod(webdavRequest) && !(DavMethods.DAV_VERSION_CONTROL == methodCode || DavMethods.DAV_REPORT == methodCode); Index: src/main/java/org/apache/jackrabbit/webdav/WebdavRequestImpl.java =================================================================== --- src/main/java/org/apache/jackrabbit/webdav/WebdavRequestImpl.java (revision 1241895) +++ src/main/java/org/apache/jackrabbit/webdav/WebdavRequestImpl.java (working copy) @@ -101,15 +101,20 @@ * * @param httpRequest * @param factory + * @param createAbsoluteURI defines if we must create a absolute URI. if false a absolute path will be created */ - public WebdavRequestImpl(HttpServletRequest httpRequest, DavLocatorFactory factory) { + public WebdavRequestImpl(HttpServletRequest httpRequest, DavLocatorFactory factory, boolean createAbsoluteURI) { this.httpRequest = httpRequest; this.factory = factory; this.ifHeader = new IfHeader(httpRequest); - String host = getHeader("Host"); - String scheme = getScheme(); - hrefPrefix = scheme + "://" + host + getContextPath(); + if (createAbsoluteURI) { + String host = getHeader("Host"); + String scheme = getScheme(); + hrefPrefix = scheme + "://" + host + getContextPath(); + } else { + hrefPrefix = getContextPath(); + } } /**