From 77a73c7475ed24edf2f3e7ff1993d550025fa075 Mon Sep 17 00:00:00 2001 From: reger Date: Wed, 16 Oct 2013 01:48:44 +0200 Subject: [PATCH] add YaCy HttpCommand "location" check to DefaultServlet --- source/net/yacy/http/YaCyDefaultServlet.java | 24 ++++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-) diff --git a/source/net/yacy/http/YaCyDefaultServlet.java b/source/net/yacy/http/YaCyDefaultServlet.java index 2aa90365d..1b2b7f6da 100644 --- a/source/net/yacy/http/YaCyDefaultServlet.java +++ b/source/net/yacy/http/YaCyDefaultServlet.java @@ -37,7 +37,6 @@ import java.util.Enumeration; import java.util.Iterator; import java.util.List; import java.util.concurrent.ConcurrentHashMap; -import java.util.zip.GZIPInputStream; import javax.servlet.RequestDispatcher; import javax.servlet.ServletContext; @@ -668,7 +667,7 @@ public abstract class YaCyDefaultServlet extends HttpServlet implements Resource return; } - servletProperties templatePatterns = null; + servletProperties templatePatterns; if (tmp == null) { // if no args given, then tp will be an empty Hashtable object (not null) templatePatterns = new servletProperties(); @@ -677,6 +676,23 @@ public abstract class YaCyDefaultServlet extends HttpServlet implements Resource } else { templatePatterns = new servletProperties((serverObjects) tmp); } + + // handle YaCy http commands + if (templatePatterns.containsKey(serverObjects.ACTION_LOCATION)) { + String location = templatePatterns.get(serverObjects.ACTION_LOCATION, ""); + + if (location.isEmpty()) { + location = request.getPathInfo(); + } + //TODO: handle equivalent of this from httpdfilehandler + // final ResponseHeader headers = getDefaultHeaders(request.getPathInfo()); + // headers.setAdditionalHeaderProperties(templatePatterns.getOutgoingHeader().getAdditionalHeaderProperties()); //put the cookies into the new header TODO: can we put all headerlines, without trouble? + + response.setHeader(HeaderFramework.LOCATION, location); + response.setStatus(HttpServletResponse.SC_FOUND); + return; + } + // add the application version, the uptime and the client name to every rewrite table templatePatterns.put(servletProperties.PEER_STAT_VERSION, yacyBuildProperties.getVersion()); templatePatterns.put(servletProperties.PEER_STAT_UPTIME, ((System.currentTimeMillis() - serverCore.startupTime) / 1000) / 60); // uptime in minutes @@ -732,7 +748,7 @@ public abstract class YaCyDefaultServlet extends HttpServlet implements Resource p = buffer.indexOf("