From 0959038624bc260c3f5fa23fa0d84c70d233390c Mon Sep 17 00:00:00 2001 From: reger Date: Sun, 18 Dec 2016 21:11:00 +0100 Subject: [PATCH] correct DefaultServlet resource pathinContext calculation exclude servletPath option as resources are always relative to htroot or htdocs, the change reflects this. Theoretically it and the recent adjustments arcording relative urls allows to configure the instance to be configurable in a path other as root (/) --- .../net/yacy/http/servlets/YaCyDefaultServlet.java | 14 +++----------- 1 file changed, 3 insertions(+), 11 deletions(-) diff --git a/source/net/yacy/http/servlets/YaCyDefaultServlet.java b/source/net/yacy/http/servlets/YaCyDefaultServlet.java index 0028b5dbd..b06b05db2 100644 --- a/source/net/yacy/http/servlets/YaCyDefaultServlet.java +++ b/source/net/yacy/http/servlets/YaCyDefaultServlet.java @@ -129,8 +129,6 @@ import com.google.common.util.concurrent.UncheckedTimeoutException; * * resourceBase Set to replace the context resource base * - * pathInfoOnly If true, only the path info will be applied to the resourceBase - * * */ public class YaCyDefaultServlet extends HttpServlet { @@ -139,7 +137,6 @@ public class YaCyDefaultServlet extends HttpServlet { protected ServletContext _servletContext; protected boolean _acceptRanges = true; protected boolean _dirAllowed = true; - protected boolean _pathInfoOnly = false; protected Resource _resourceBase; protected MimeTypes _mimeTypes; protected String[] _welcomes; @@ -172,7 +169,6 @@ public class YaCyDefaultServlet extends HttpServlet { } _acceptRanges = getInitBoolean("acceptRanges", _acceptRanges); _dirAllowed = getInitBoolean("dirAllowed", _dirAllowed); - _pathInfoOnly = getInitBoolean("pathInfoOnly", _pathInfoOnly); Resource.setDefaultUseCaches(false); // caching is handled internally (prevent double caching) @@ -245,19 +241,15 @@ public class YaCyDefaultServlet extends HttpServlet { @Override protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { - String servletPath; String pathInfo; Enumeration reqRanges = null; boolean included = request.getAttribute(RequestDispatcher.INCLUDE_REQUEST_URI) != null; if (included) { - servletPath = (String) request.getAttribute(RequestDispatcher.INCLUDE_SERVLET_PATH); pathInfo = (String) request.getAttribute(RequestDispatcher.INCLUDE_PATH_INFO); - if (servletPath == null) { - servletPath = request.getServletPath(); + if (pathInfo == null) { pathInfo = request.getPathInfo(); } } else { - servletPath = _pathInfoOnly ? "/" : request.getServletPath(); pathInfo = request.getPathInfo(); // Is this a Range request? @@ -267,8 +259,8 @@ public class YaCyDefaultServlet extends HttpServlet { } } - String pathInContext = URIUtil.addPaths(servletPath, pathInfo); - boolean endsWithSlash = (pathInfo == null ? request.getServletPath() : pathInfo).endsWith(URIUtil.SLASH); + String pathInContext = pathInfo == null ? "/" : pathInfo; // this is the path of the resource in _resourceBase (= path within htroot respective htDocs) + boolean endsWithSlash = pathInContext.endsWith(URIUtil.SLASH); // Find the resource Resource resource = null;