incubator-sling-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bdelacre...@apache.org
Subject svn commit: r612806 - /incubator/sling/trunk/sling/servlet-resolver/src/main/java/org/apache/sling/servlet/resolver/helper/SlingScriptServlet.java
Date Thu, 17 Jan 2008 13:06:53 GMT
Author: bdelacretaz
Date: Thu Jan 17 05:06:09 2008
New Revision: 612806

URL: http://svn.apache.org/viewvc?rev=612806&view=rev
Log:
X-Sling-Warning header indicates missing Content-Type

Modified:
    incubator/sling/trunk/sling/servlet-resolver/src/main/java/org/apache/sling/servlet/resolver/helper/SlingScriptServlet.java

Modified: incubator/sling/trunk/sling/servlet-resolver/src/main/java/org/apache/sling/servlet/resolver/helper/SlingScriptServlet.java
URL: http://svn.apache.org/viewvc/incubator/sling/trunk/sling/servlet-resolver/src/main/java/org/apache/sling/servlet/resolver/helper/SlingScriptServlet.java?rev=612806&r1=612805&r2=612806&view=diff
==============================================================================
--- incubator/sling/trunk/sling/servlet-resolver/src/main/java/org/apache/sling/servlet/resolver/helper/SlingScriptServlet.java
(original)
+++ incubator/sling/trunk/sling/servlet-resolver/src/main/java/org/apache/sling/servlet/resolver/helper/SlingScriptServlet.java
Thu Jan 17 05:06:09 2008
@@ -30,6 +30,7 @@
 import javax.servlet.ServletException;
 import javax.servlet.ServletRequest;
 import javax.servlet.ServletResponse;
+import javax.servlet.http.HttpServletResponse;
 
 import org.apache.sling.api.SlingException;
 import org.apache.sling.api.SlingHttpServletRequest;
@@ -55,10 +56,11 @@
         this.script = script;
     }
 
-    public void service(ServletRequest req, ServletResponse res)
+    public void service(ServletRequest req, ServletResponse servletResponse)
             throws ServletException, IOException {
 
         SlingHttpServletRequest request = (SlingHttpServletRequest) req;
+        final HttpServletResponse res = (HttpServletResponse)servletResponse;
 
         try {
             // prepare the properties for the script
@@ -68,7 +70,13 @@
             props.put(FLUSH, TRUE);
 
             res.setCharacterEncoding("UTF-8");
-            res.setContentType(request.getResponseContentType());
+            final String contentType = request.getResponseContentType();
+            if(contentType == null) {
+                res.addHeader("X-Sling-Warning", request.getClass().getSimpleName() + " does
not provide a Content-Type");
+                res.setContentType("text/plain");
+            } else {
+                res.setContentType(contentType);
+            }
 
             // evaluate the script now using the ScriptEngine
             script.eval(props);



Mime
View raw message