tomcat-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ma...@apache.org
Subject svn commit: r1354855 - in /tomcat/trunk/java: javax/servlet/ javax/servlet/http/ org/apache/catalina/core/ org/apache/catalina/servlets/
Date Thu, 28 Jun 2012 08:23:13 GMT
Author: markt
Date: Thu Jun 28 08:23:12 2012
New Revision: 1354855

URL: http://svn.apache.org/viewvc?rev=1354855&view=rev
Log:
Servlet 3.1 - setContentLengthLong

Modified:
    tomcat/trunk/java/javax/servlet/ServletResponseWrapper.java
    tomcat/trunk/java/javax/servlet/http/HttpServlet.java
    tomcat/trunk/java/org/apache/catalina/core/ApplicationHttpResponse.java
    tomcat/trunk/java/org/apache/catalina/core/ApplicationResponse.java
    tomcat/trunk/java/org/apache/catalina/servlets/DefaultServlet.java

Modified: tomcat/trunk/java/javax/servlet/ServletResponseWrapper.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/javax/servlet/ServletResponseWrapper.java?rev=1354855&r1=1354854&r2=1354855&view=diff
==============================================================================
--- tomcat/trunk/java/javax/servlet/ServletResponseWrapper.java (original)
+++ tomcat/trunk/java/javax/servlet/ServletResponseWrapper.java Thu Jun 28 08:23:12 2012
@@ -115,7 +115,8 @@ public class ServletResponseWrapper impl
     }
 
     /**
-     * TODO SERVLET 3.1
+     * The default behavior of this method is to call setContentLength(long len)
+     * on the wrapped response object.
      */
     @Override
     public void setContentLengthLong(long length) {

Modified: tomcat/trunk/java/javax/servlet/http/HttpServlet.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/javax/servlet/http/HttpServlet.java?rev=1354855&r1=1354854&r2=1354855&view=diff
==============================================================================
--- tomcat/trunk/java/javax/servlet/http/HttpServlet.java (original)
+++ tomcat/trunk/java/javax/servlet/http/HttpServlet.java Thu Jun 28 08:23:12 2012
@@ -758,6 +758,12 @@ class NoBodyResponse extends HttpServlet
     }
 
     @Override
+    public void setContentLengthLong(long len) {
+        super.setContentLengthLong(len);
+        didSetContentLength = true;
+    }
+
+    @Override
     public void setHeader(String name, String value) {
         super.setHeader(name, value);
         if ("content-length".equalsIgnoreCase(name)) {

Modified: tomcat/trunk/java/org/apache/catalina/core/ApplicationHttpResponse.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/catalina/core/ApplicationHttpResponse.java?rev=1354855&r1=1354854&r2=1354855&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/catalina/core/ApplicationHttpResponse.java (original)
+++ tomcat/trunk/java/org/apache/catalina/core/ApplicationHttpResponse.java Thu Jun 28 08:23:12
2012
@@ -89,7 +89,8 @@ class ApplicationHttpResponse extends Ht
 
 
     /**
-     * Disallow <code>setContentLength()</code> calls on an included response.
+     * Disallow <code>setContentLength(int)</code> calls on an included
+     * response.
      *
      * @param len The new content length
      */
@@ -103,6 +104,21 @@ class ApplicationHttpResponse extends Ht
 
 
     /**
+     * Disallow <code>setContentLengthLong(long)</code> calls on an included
+     * response.
+     *
+     * @param len The new content length
+     */
+    @Override
+    public void setContentLengthLong(long len) {
+
+        if (!included)
+            getResponse().setContentLengthLong(len);
+
+    }
+
+
+    /**
      * Disallow <code>setContentType()</code> calls on an included response.
      *
      * @param type The new content type

Modified: tomcat/trunk/java/org/apache/catalina/core/ApplicationResponse.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/catalina/core/ApplicationResponse.java?rev=1354855&r1=1354854&r2=1354855&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/catalina/core/ApplicationResponse.java (original)
+++ tomcat/trunk/java/org/apache/catalina/core/ApplicationResponse.java Thu Jun 28 08:23:12
2012
@@ -87,7 +87,8 @@ class ApplicationResponse extends Servle
 
 
     /**
-     * Disallow <code>setContentLength()</code> calls on an included response.
+     * Disallow <code>setContentLength(int)</code> calls on an included
+     * response.
      *
      * @param len The new content length
      */
@@ -101,6 +102,21 @@ class ApplicationResponse extends Servle
 
 
     /**
+     * Disallow <code>setContentLengthLong(long)</code> calls on an included
+     * response.
+     *
+     * @param len The new content length
+     */
+    @Override
+    public void setContentLengthLong(long len) {
+
+        if (!included)
+            getResponse().setContentLengthLong(len);
+
+    }
+
+
+    /**
      * Disallow <code>setContentType()</code> calls on an included response.
      *
      * @param type The new content type

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=1354855&r1=1354854&r2=1354855&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/catalina/servlets/DefaultServlet.java (original)
+++ tomcat/trunk/java/org/apache/catalina/servlets/DefaultServlet.java Thu Jun 28 08:23:12
2012
@@ -909,14 +909,7 @@ public class DefaultServlet
                 // Don't set a content length if something else has already
                 // written to the response.
                 if (contentWritten == 0) {
-                    if (contentLength < Integer.MAX_VALUE) {
-                        response.setContentLength((int) contentLength);
-                    } else {
-                        // Set the content-length as String to be able to use a
-                        // long
-                        response.setHeader("content-length",
-                                "" + contentLength);
-                    }
+                    response.setContentLengthLong(contentLength);
                 }
             }
 
@@ -962,12 +955,7 @@ public class DefaultServlet
                                    + "-" + range.end + "/"
                                    + range.length);
                 long length = range.end - range.start + 1;
-                if (length < Integer.MAX_VALUE) {
-                    response.setContentLength((int) length);
-                } else {
-                    // Set the content-length as String to be able to use a long
-                    response.setHeader("content-length", "" + length);
-                }
+                response.setContentLengthLong(length);
 
                 if (contentType != null) {
                     if (debug > 0)



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


Mime
View raw message