tomcat-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ma...@apache.org
Subject svn commit: r696408 - in /tomcat/trunk: conf/web.xml java/org/apache/catalina/servlets/DefaultServlet.java webapps/docs/default-servlet.xml
Date Wed, 17 Sep 2008 19:26:23 GMT
Author: markt
Date: Wed Sep 17 12:26:22 2008
New Revision: 696408

URL: http://svn.apache.org/viewvc?rev=696408&view=rev
Log:
Fix https://issues.apache.org/bugzilla/show_bug.cgi?id=45419
Set the Accept-Ranges header on content served from the DefaultServlet. This can be disabled
via configuration if required.

Modified:
    tomcat/trunk/conf/web.xml
    tomcat/trunk/java/org/apache/catalina/servlets/DefaultServlet.java
    tomcat/trunk/webapps/docs/default-servlet.xml

Modified: tomcat/trunk/conf/web.xml
URL: http://svn.apache.org/viewvc/tomcat/trunk/conf/web.xml?rev=696408&r1=696407&r2=696408&view=diff
==============================================================================
--- tomcat/trunk/conf/web.xml (original)
+++ tomcat/trunk/conf/web.xml Wed Sep 17 12:26:22 2008
@@ -70,6 +70,9 @@
   <!--                       which sendfile will be used. Use a negative    -->
   <!--                       value to always disable sendfile.  [48]        -->
   <!--                                                                      -->
+  <!--   useAcceptRanges     Should the Accept-Ranges header be included    -->
+  <!--                       in responses where appropriate? [true]         -->
+  <!--                                                                      -->
   <!--  For directory listing customization. Checks localXsltFile, then     -->
   <!--  globalXsltFile, then defaults to original behavior.                 -->
   <!--                                                                      -->

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=696408&r1=696407&r2=696408&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/catalina/servlets/DefaultServlet.java (original)
+++ tomcat/trunk/java/org/apache/catalina/servlets/DefaultServlet.java Wed Sep 17 12:26:22
2008
@@ -154,7 +154,11 @@
      */
     protected int sendfileSize = 48 * 1024;
     
-    
+    /**
+     * Should the Accept-Ranges: bytes header be send with static resources?
+     */
+    protected boolean useAcceptRanges = true;
+
     /**
      * Full range marker.
      */
@@ -241,6 +245,9 @@
         localXsltFile = getServletConfig().getInitParameter("localXsltFile");
         readmeFile = getServletConfig().getInitParameter("readmeFile");
 
+        if (getServletConfig().getInitParameter("useAcceptRanges") != null)
+            useAcceptRanges = Boolean.parseBoolean(getServletConfig().getInitParameter("useAcceptRanges"));
+
         // Sanity check on the specified buffer sizes
         if (input < 256)
             input = 256;
@@ -717,9 +724,12 @@
             contentType = "text/html;charset=UTF-8";
 
         } else {
+            if (useAcceptRanges) {
+                // Accept ranges header
+                response.setHeader("Accept-Ranges", "bytes");
+            }
 
             // Parse range specifier
-
             ranges = parseRange(request, response, cacheEntry.attributes);
 
             // ETag header

Modified: tomcat/trunk/webapps/docs/default-servlet.xml
URL: http://svn.apache.org/viewvc/tomcat/trunk/webapps/docs/default-servlet.xml?rev=696408&r1=696407&r2=696408&view=diff
==============================================================================
--- tomcat/trunk/webapps/docs/default-servlet.xml (original)
+++ tomcat/trunk/webapps/docs/default-servlet.xml Wed Sep 17 12:26:22 2008
@@ -179,6 +179,13 @@
         to always disable sendfile. [48]
     </td>
   </tr>
+  <tr>
+    <th valign='top'>useAcceptRanges</th>
+    <td valign='top'>
+        If true, the Accept-Ranges header will be set when appropriate for the
+        response. [true]
+    </td>
+  </tr>
 
 </table>
 </section>



---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org


Mime
View raw message