incubator-sling-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From fmesc...@apache.org
Subject svn commit: r889379 - /sling/trunk/bundles/servlets/get/src/main/java/org/apache/sling/servlets/get/impl/RedirectServlet.java
Date Thu, 10 Dec 2009 19:37:21 GMT
Author: fmeschbe
Date: Thu Dec 10 19:37:20 2009
New Revision: 889379

URL: http://svn.apache.org/viewvc?rev=889379&view=rev
Log:
SLING-1087 Don't redirect if the response is committed or the redirect servlet is called for
an included resource

Modified:
    sling/trunk/bundles/servlets/get/src/main/java/org/apache/sling/servlets/get/impl/RedirectServlet.java

Modified: sling/trunk/bundles/servlets/get/src/main/java/org/apache/sling/servlets/get/impl/RedirectServlet.java
URL: http://svn.apache.org/viewvc/sling/trunk/bundles/servlets/get/src/main/java/org/apache/sling/servlets/get/impl/RedirectServlet.java?rev=889379&r1=889378&r2=889379&view=diff
==============================================================================
--- sling/trunk/bundles/servlets/get/src/main/java/org/apache/sling/servlets/get/impl/RedirectServlet.java
(original)
+++ sling/trunk/bundles/servlets/get/src/main/java/org/apache/sling/servlets/get/impl/RedirectServlet.java
Thu Dec 10 19:37:20 2009
@@ -24,6 +24,7 @@
 import javax.servlet.ServletException;
 import javax.servlet.http.HttpServletResponse;
 
+import org.apache.sling.api.SlingConstants;
 import org.apache.sling.api.SlingHttpServletRequest;
 import org.apache.sling.api.SlingHttpServletResponse;
 import org.apache.sling.api.request.RequestPathInfo;
@@ -32,6 +33,8 @@
 import org.apache.sling.api.resource.ValueMap;
 import org.apache.sling.api.servlets.SlingSafeMethodsServlet;
 import org.apache.sling.servlets.get.impl.helpers.JsonRendererServlet;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
 /**
  * The <code>RedirectServlet</code> implements support for GET requests to
@@ -63,6 +66,9 @@
     /** The name of the target property */
     public static final String TARGET_PROP = "sling:target";
 
+    /** default log */
+    private final Logger log = LoggerFactory.getLogger(getClass());
+
     private Servlet jsonRendererServlet;
 
     @Override
@@ -76,6 +82,17 @@
             return;
         }
 
+        // check for redirectability
+        if (response.isCommitted()) {
+            // committed response cannot be redirected
+            log.warn("doGet: Response is already committed, not redirecting");
+            return;
+        } else if (request.getAttribute(SlingConstants.ATTR_REQUEST_SERVLET) != null) {
+            // included request will not redirect
+            log.warn("doGet: Servlet is included, not redirecting");
+            return;
+        }
+
         String targetPath = null;
 
         // convert resource to a value map
@@ -128,7 +145,6 @@
         // if the target path is an URL, do nothing and return it unmodified
         final RequestPathInfo rpi = request.getRequestPathInfo();
 
-
         // make sure the target path is absolute
         final String rawAbsPath;
         if (targetPath.startsWith("/")) {



Mime
View raw message