You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@sling.apache.org by ra...@apache.org on 2019/08/13 16:43:29 UTC

[sling-org-apache-sling-scripting-bundle-tracker] branch master updated: corrected behaviour for dispatching servlet

This is an automated email from the ASF dual-hosted git repository.

radu pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-scripting-bundle-tracker.git


The following commit(s) were added to refs/heads/master by this push:
     new 18be7c4  corrected behaviour for dispatching servlet
18be7c4 is described below

commit 18be7c41577d697d38b2d431650b6b706251c412
Author: Radu Cotescu <ra...@apache.org>
AuthorDate: Tue Aug 13 18:43:20 2019 +0200

    corrected behaviour for dispatching servlet
---
 .../bundle/tracker/internal/BundledScriptTracker.java        | 12 +++++++++++-
 1 file changed, 11 insertions(+), 1 deletion(-)

diff --git a/src/main/java/org/apache/sling/scripting/bundle/tracker/internal/BundledScriptTracker.java b/src/main/java/org/apache/sling/scripting/bundle/tracker/internal/BundledScriptTracker.java
index 5e70600..6a06ec3 100644
--- a/src/main/java/org/apache/sling/scripting/bundle/tracker/internal/BundledScriptTracker.java
+++ b/src/main/java/org/apache/sling/scripting/bundle/tracker/internal/BundledScriptTracker.java
@@ -43,6 +43,7 @@ import javax.servlet.ServletResponse;
 import javax.servlet.http.HttpServletResponse;
 
 import org.apache.commons.lang3.StringUtils;
+import org.apache.sling.api.SlingConstants;
 import org.apache.sling.api.SlingHttpServletRequest;
 import org.apache.sling.api.SlingHttpServletResponse;
 import org.apache.sling.api.request.RequestDispatcherOptions;
@@ -382,7 +383,16 @@ public class BundledScriptTracker implements BundleTrackerCustomizer<List<Servic
 
                 RequestDispatcher dispatcher = slingRequest.getRequestDispatcher(slingRequest.getResource(), options);
                 if (dispatcher != null) {
-                    dispatcher.forward(req, res);
+                    if (slingRequest.getAttribute(SlingConstants.ATTR_INCLUDE_SERVLET_PATH) == null) {
+                        final String contentType = slingRequest.getResponseContentType();
+                        if (contentType != null) {
+                            res.setContentType(contentType);
+                            if (contentType.startsWith("text/")) {
+                                res.setCharacterEncoding("UTF-8");
+                            }
+                        }
+                    }
+                    dispatcher.include(req, res);
                 } else {
                     ((SlingHttpServletResponse) res).sendError(HttpServletResponse.SC_NOT_FOUND);
                 }