From 17c12459a5ef09a7674ef91ccab32dbe97a8cb48 Mon Sep 17 00:00:00 2001 From: "Eric J. Bowersox" Date: Sat, 6 Nov 2004 02:20:58 +0000 Subject: [PATCH] additional change to cause crawlers to never get munged URLs, always get the raw servlet URL --- scripts/session_init.js | 3 ++ .../silverwrist/venice/ui/RequestInput.java | 2 + .../venice/ui/helpers/SessionKiller.java | 10 +++++ .../venice/ui/servlet/RequestImpl.java | 41 +++++++++++++++++-- 4 files changed, 53 insertions(+), 3 deletions(-) diff --git a/scripts/session_init.js b/scripts/session_init.js index f5c050d..8c5db50 100644 --- a/scripts/session_init.js +++ b/scripts/session_init.js @@ -31,6 +31,9 @@ if (binfo.hasCapability("crawler") || binfo.hasCapability("stripper")) logger.debug("this session is a crawler, it will be killed"); sess.setMaxInactiveInterval(30); + // don't encode any servlet paths we send + rinput.setSpecial("No-Session-Encode","true"); + // the session will be killed at the end of the request anyway rinput.registerCleanup(new SessionKiller(sess)); diff --git a/src/com/silverwrist/venice/ui/RequestInput.java b/src/com/silverwrist/venice/ui/RequestInput.java index ca4e59c..5bcad4f 100644 --- a/src/com/silverwrist/venice/ui/RequestInput.java +++ b/src/com/silverwrist/venice/ui/RequestInput.java @@ -364,4 +364,6 @@ public interface RequestInput extends ServiceProvider public String getConfigProperty(String name, String default_val); + public void setSpecial(String name, String value); + } // end interface RequestInput diff --git a/src/com/silverwrist/venice/ui/helpers/SessionKiller.java b/src/com/silverwrist/venice/ui/helpers/SessionKiller.java index 501fecb..cee2a55 100644 --- a/src/com/silverwrist/venice/ui/helpers/SessionKiller.java +++ b/src/com/silverwrist/venice/ui/helpers/SessionKiller.java @@ -17,10 +17,18 @@ */ package com.silverwrist.venice.ui.helpers; +import org.apache.log4j.Logger; import com.silverwrist.venice.ui.*; public class SessionKiller implements AutoCleanup { + /*-------------------------------------------------------------------------------- + * Static data members + *-------------------------------------------------------------------------------- + */ + + private static Logger logger = Logger.getLogger(SessionKiller.class); + /*-------------------------------------------------------------------------------- * Attributes *-------------------------------------------------------------------------------- @@ -46,6 +54,8 @@ public class SessionKiller implements AutoCleanup public void cleanup() { + if (logger.isDebugEnabled()) + logger.debug("SessionKiller killing session " + m_sess.getID()); m_sess.invalidate(); } // end cleanup diff --git a/src/com/silverwrist/venice/ui/servlet/RequestImpl.java b/src/com/silverwrist/venice/ui/servlet/RequestImpl.java index a5ada66..2226abd 100644 --- a/src/com/silverwrist/venice/ui/servlet/RequestImpl.java +++ b/src/com/silverwrist/venice/ui/servlet/RequestImpl.java @@ -453,9 +453,26 @@ public class RequestImpl implements RequestInput if (type==ABSOLUTE) fmt_url = where; else if (type==SERVLET) - fmt_url = response.encodeRedirectURL(request.getContextPath() + "/" + where); + { // servlet + fmt_url = request.getContextPath() + "/" + where; + if (!m_no_session_encode) + fmt_url = response.encodeRedirectURL(fmt_url); + + } // end else if else if (type==FRAME) - fmt_url = response.encodeRedirectURL(request.getContextPath() + "/frame/" + where); + { // frame + fmt_url = request.getContextPath() + "/frame/" + where; + if (!m_no_session_encode) + fmt_url = response.encodeRedirectURL(fmt_url); + + } // end else if + else if (type==FULLSERVLET) + { // full servlet + fmt_url = expandServletPath(where,false); + if (!m_no_session_encode) + fmt_url = response.encodeRedirectURL(fmt_url); + + } // end else if else throw new IndexOutOfBoundsException("invalid format type index for redirect"); @@ -595,6 +612,7 @@ public class RequestImpl implements RequestInput private ScriptSupportImpl script_support = null; // script support interface private ResourceLoaderImpl m_resource_loader = null; // resource loader interface private BrowserInformationImpl m_browser_info = null; // browser information interface + private boolean m_no_session_encode = false; // override session encoding? /*-------------------------------------------------------------------------------- * Constructor @@ -838,7 +856,10 @@ public class RequestImpl implements RequestInput final String encodeServletPath(String servlet) { - return response.encodeURL(request.getContextPath() + "/" + servlet); + if (m_no_session_encode) + return request.getContextPath() + "/" + servlet; + else + return response.encodeURL(request.getContextPath() + "/" + servlet); } // end encodeServletPath @@ -1638,6 +1659,20 @@ public class RequestImpl implements RequestInput } // end getConfigProperty + public void setSpecial(String name, String value) + { + if (name.equals("No-Session-Encode")) + { // the special name "No-Session-Encode" + if (StringUtil.isBooleanTrue(value)) + m_no_session_encode = true; + else if (StringUtil.isBooleanFalse(value)) + m_no_session_encode = false; + return; + + } // end if + + } // end setSpecial + /*-------------------------------------------------------------------------------- * External static operations *--------------------------------------------------------------------------------