svn commit: r1845799 - in /tomcat/trunk: java/org/apache/catalina/servlets/DefaultServlet.java webapps/docs/changelog.xml

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

svn commit: r1845799 - in /tomcat/trunk: java/org/apache/catalina/servlets/DefaultServlet.java webapps/docs/changelog.xml

Rémy Maucherat
Author: remm
Date: Mon Nov  5 14:14:41 2018
New Revision: 1845799

URL: http://svn.apache.org/viewvc?rev=1845799&view=rev
Log:
As reported by Konstantin, it could be beneficial in some cases that the default servlet does not override the content type.

Modified:
    tomcat/trunk/java/org/apache/catalina/servlets/DefaultServlet.java
    tomcat/trunk/webapps/docs/changelog.xml

Modified: tomcat/trunk/java/org/apache/catalina/servlets/DefaultServlet.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/catalina/servlets/DefaultServlet.java?rev=1845799&r1=1845798&r2=1845799&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/catalina/servlets/DefaultServlet.java (original)
+++ tomcat/trunk/java/org/apache/catalina/servlets/DefaultServlet.java Mon Nov  5 14:14:41 2018
@@ -994,7 +994,10 @@ public class DefaultServlet extends Http
                 if (debug > 0)
                     log("DefaultServlet.serveFile:  contentType='" +
                         contentType + "'");
-                response.setContentType(contentType);
+                // Don't override a previously set content type
+                if (response.getContentType() == null) {
+                    response.setContentType(contentType);
+                }
             }
             if (resource.isFile() && contentLength >= 0 &&
                     (!serveContent || ostream != null)) {

Modified: tomcat/trunk/webapps/docs/changelog.xml
URL: http://svn.apache.org/viewvc/tomcat/trunk/webapps/docs/changelog.xml?rev=1845799&r1=1845798&r2=1845799&view=diff
==============================================================================
--- tomcat/trunk/webapps/docs/changelog.xml (original)
+++ tomcat/trunk/webapps/docs/changelog.xml Mon Nov  5 14:14:41 2018
@@ -52,6 +52,10 @@
         using UTF-8 to align with Tomcat's use of UTF-8 by default
         elsewhere. (markt)
       </fix>
+      <fix>
+        The default Servlet should not override a previously set content-type.
+        (remm)
+      </fix>
     </changelog>
   </subsection>
 </section>



---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]