tomcat-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ma...@apache.org
Subject svn commit: r1239298 - in /tomcat/trunk/java/org/apache: catalina/ catalina/connector/ catalina/servlets/ catalina/valves/ coyote/ coyote/http11/
Date Wed, 01 Feb 2012 20:11:26 GMT
Author: markt
Date: Wed Feb  1 20:11:26 2012
New Revision: 1239298

URL: http://svn.apache.org/viewvc?rev=1239298&view=rev
Log:
Plumb in the remaining constants

Modified:
    tomcat/trunk/java/org/apache/catalina/Globals.java
    tomcat/trunk/java/org/apache/catalina/connector/Request.java
    tomcat/trunk/java/org/apache/catalina/servlets/DefaultServlet.java
    tomcat/trunk/java/org/apache/catalina/valves/AccessLogValve.java
    tomcat/trunk/java/org/apache/coyote/Constants.java
    tomcat/trunk/java/org/apache/coyote/http11/AbstractHttp11Processor.java
    tomcat/trunk/java/org/apache/coyote/http11/Http11AprProcessor.java
    tomcat/trunk/java/org/apache/coyote/http11/Http11NioProcessor.java

Modified: tomcat/trunk/java/org/apache/catalina/Globals.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/catalina/Globals.java?rev=1239298&r1=1239297&r2=1239298&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/catalina/Globals.java (original)
+++ tomcat/trunk/java/org/apache/catalina/Globals.java Wed Feb  1 20:11:26 2012
@@ -177,9 +177,11 @@ public final class Globals {
     /**
      * The request attribute that is set to the value of {@code Boolean.TRUE}
      * if connector processing this request supports use of sendfile.
+     *
+     * Duplicated here for neater code in the catalina packages.
      */
     public static final String SENDFILE_SUPPORTED_ATTR =
-        "org.apache.tomcat.sendfile.support";
+            org.apache.coyote.Constants.SENDFILE_SUPPORTED_ATTR;
 
 
     /**
@@ -187,9 +189,11 @@ public final class Globals {
      * to the connector the name of the file that is to be served
      * by sendfile. The value should be {@code java.lang.String}
      * that is {@code File.getCanonicalPath()} of the file to be served.
+     *
+     * Duplicated here for neater code in the catalina packages.
      */
     public static final String SENDFILE_FILENAME_ATTR =
-        "org.apache.tomcat.sendfile.filename";
+            org.apache.coyote.Constants.SENDFILE_FILENAME_ATTR;
 
 
     /**
@@ -198,9 +202,11 @@ public final class Globals {
      * that is to be served by sendfile. The value should be
      * {@code java.lang.Long}. To serve complete file
      * the value should be {@code Long.valueOf(0)}.
+     *
+     * Duplicated here for neater code in the catalina packages.
      */
     public static final String SENDFILE_FILE_START_ATTR =
-        "org.apache.tomcat.sendfile.start";
+            org.apache.coyote.Constants.SENDFILE_FILE_START_ATTR;
 
 
     /**
@@ -209,9 +215,11 @@ public final class Globals {
      * of a file that is to be served by sendfile. The value should be
      * {@code java.lang.Long}. To serve complete file
      * the value should be equal to the length of the file.
+     *
+     * Duplicated here for neater code in the catalina packages.
      */
     public static final String SENDFILE_FILE_END_ATTR =
-        "org.apache.tomcat.sendfile.end";
+            org.apache.coyote.Constants.SENDFILE_FILE_END_ATTR;
 
 
     /**

Modified: tomcat/trunk/java/org/apache/catalina/connector/Request.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/catalina/connector/Request.java?rev=1239298&r1=1239297&r2=1239298&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/catalina/connector/Request.java (original)
+++ tomcat/trunk/java/org/apache/catalina/connector/Request.java Wed Feb  1 20:11:26 2012
@@ -1449,7 +1449,7 @@ public class Request
 
         // Do the security check before any updates are made
         if (Globals.IS_SECURITY_ENABLED &&
-                name.equals("org.apache.tomcat.sendfile.filename")) {
+                name.equals(Globals.SENDFILE_FILENAME_ATTR)) {
             // Use the canonical file name to avoid any possible symlink and
             // relative path issues
             String canonicalPath;

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=1239298&r1=1239297&r2=1239298&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/catalina/servlets/DefaultServlet.java (original)
+++ tomcat/trunk/java/org/apache/catalina/servlets/DefaultServlet.java Wed Feb  1 20:11:26
2012
@@ -1641,16 +1641,16 @@ public class DefaultServlet
             && (entry.resource != null)
             && ((length > sendfileSize) || (entry.resource.getContent() == null))
             && (entry.attributes.getCanonicalPath() != null)
-            && (Boolean.TRUE == request.getAttribute("org.apache.tomcat.sendfile.support"))
+            && (Boolean.TRUE == request.getAttribute(Globals.SENDFILE_SUPPORTED_ATTR))
             && (request.getClass().getName().equals("org.apache.catalina.connector.RequestFacade"))
             && (response.getClass().getName().equals("org.apache.catalina.connector.ResponseFacade")))
{
-            request.setAttribute("org.apache.tomcat.sendfile.filename", entry.attributes.getCanonicalPath());
+            request.setAttribute(Globals.SENDFILE_FILENAME_ATTR, entry.attributes.getCanonicalPath());
             if (range == null) {
-                request.setAttribute("org.apache.tomcat.sendfile.start", Long.valueOf(0L));
-                request.setAttribute("org.apache.tomcat.sendfile.end", Long.valueOf(length));
+                request.setAttribute(Globals.SENDFILE_FILE_START_ATTR, Long.valueOf(0L));
+                request.setAttribute(Globals.SENDFILE_FILE_END_ATTR, Long.valueOf(length));
             } else {
-                request.setAttribute("org.apache.tomcat.sendfile.start", Long.valueOf(range.start));
-                request.setAttribute("org.apache.tomcat.sendfile.end", Long.valueOf(range.end
+ 1));
+                request.setAttribute(Globals.SENDFILE_FILE_START_ATTR, Long.valueOf(range.start));
+                request.setAttribute(Globals.SENDFILE_FILE_END_ATTR, Long.valueOf(range.end
+ 1));
             }
             return true;
         }

Modified: tomcat/trunk/java/org/apache/catalina/valves/AccessLogValve.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/catalina/valves/AccessLogValve.java?rev=1239298&r1=1239297&r2=1239298&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/catalina/valves/AccessLogValve.java (original)
+++ tomcat/trunk/java/org/apache/catalina/valves/AccessLogValve.java Wed Feb  1 20:11:26 2012
@@ -1621,10 +1621,10 @@ public class AccessLogValve extends Valv
                 // Protect against nulls and unexpected types as these values
                 // may be set by untrusted applications
                 Object start = request.getAttribute(
-                        "org.apache.tomcat.sendfile.start");
+                        Globals.SENDFILE_FILE_START_ATTR);
                 if (start instanceof Long) {
                     Object end = request.getAttribute(
-                            "org.apache.tomcat.sendfile.end");
+                            Globals.SENDFILE_FILE_END_ATTR);
                     if (end instanceof Long) {
                         length = ((Long) end).longValue() -
                                 ((Long) start).longValue();

Modified: tomcat/trunk/java/org/apache/coyote/Constants.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/coyote/Constants.java?rev=1239298&r1=1239297&r2=1239298&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/coyote/Constants.java (original)
+++ tomcat/trunk/java/org/apache/coyote/Constants.java Wed Feb  1 20:11:26 2012
@@ -88,4 +88,44 @@ public final class Constants {
      */
     public static final String COMET_TIMEOUT_ATTR =
         "org.apache.tomcat.comet.timeout";
+
+
+    /**
+     * The request attribute that is set to the value of {@code Boolean.TRUE}
+     * if connector processing this request supports use of sendfile.
+     */
+    public static final String SENDFILE_SUPPORTED_ATTR =
+        "org.apache.tomcat.sendfile.support";
+
+
+    /**
+     * The request attribute that can be used by a servlet to pass
+     * to the connector the name of the file that is to be served
+     * by sendfile. The value should be {@code java.lang.String}
+     * that is {@code File.getCanonicalPath()} of the file to be served.
+     */
+    public static final String SENDFILE_FILENAME_ATTR =
+        "org.apache.tomcat.sendfile.filename";
+
+
+    /**
+     * The request attribute that can be used by a servlet to pass
+     * to the connector the start offset of the part of a file
+     * that is to be served by sendfile. The value should be
+     * {@code java.lang.Long}. To serve complete file
+     * the value should be {@code Long.valueOf(0)}.
+     */
+    public static final String SENDFILE_FILE_START_ATTR =
+        "org.apache.tomcat.sendfile.start";
+
+
+    /**
+     * The request attribute that can be used by a servlet to pass
+     * to the connector the end offset (not including) of the part
+     * of a file that is to be served by sendfile. The value should be
+     * {@code java.lang.Long}. To serve complete file
+     * the value should be equal to the length of the file.
+     */
+    public static final String SENDFILE_FILE_END_ATTR =
+        "org.apache.tomcat.sendfile.end";
 }

Modified: tomcat/trunk/java/org/apache/coyote/http11/AbstractHttp11Processor.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/coyote/http11/AbstractHttp11Processor.java?rev=1239298&r1=1239297&r2=1239298&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/coyote/http11/AbstractHttp11Processor.java (original)
+++ tomcat/trunk/java/org/apache/coyote/http11/AbstractHttp11Processor.java Wed Feb  1 20:11:26
2012
@@ -1273,7 +1273,8 @@ public abstract class AbstractHttp11Proc
 
         // Advertise sendfile support through a request attribute
         if (endpoint.getUseSendfile()) {
-            request.setAttribute("org.apache.tomcat.sendfile.support",
+            request.setAttribute(
+                    org.apache.coyote.Constants.SENDFILE_SUPPORTED_ATTR,
                     Boolean.TRUE);
         }
 

Modified: tomcat/trunk/java/org/apache/coyote/http11/Http11AprProcessor.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/coyote/http11/Http11AprProcessor.java?rev=1239298&r1=1239297&r2=1239298&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/coyote/http11/Http11AprProcessor.java (original)
+++ tomcat/trunk/java/org/apache/coyote/http11/Http11AprProcessor.java Wed Feb  1 20:11:26
2012
@@ -486,7 +486,7 @@ public class Http11AprProcessor extends 
     @Override
     protected boolean prepareSendfile(OutputFilter[] outputFilters) {
         String fileName = (String) request.getAttribute(
-                "org.apache.tomcat.sendfile.filename");
+                org.apache.coyote.Constants.SENDFILE_FILENAME_ATTR);
         if (fileName != null) {
             // No entity body sent here
             outputBuffer.addActiveFilter(outputFilters[Constants.VOID_FILTER]);
@@ -494,9 +494,9 @@ public class Http11AprProcessor extends 
             sendfileData = new AprEndpoint.SendfileData();
             sendfileData.fileName = fileName;
             sendfileData.start = ((Long) request.getAttribute(
-                    "org.apache.tomcat.sendfile.start")).longValue();
+                    org.apache.coyote.Constants.SENDFILE_FILE_START_ATTR)).longValue();
             sendfileData.end = ((Long) request.getAttribute(
-                    "org.apache.tomcat.sendfile.end")).longValue();
+                    org.apache.coyote.Constants.SENDFILE_FILE_END_ATTR)).longValue();
             return true;
         }
         return false;

Modified: tomcat/trunk/java/org/apache/coyote/http11/Http11NioProcessor.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/coyote/http11/Http11NioProcessor.java?rev=1239298&r1=1239297&r2=1239298&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/coyote/http11/Http11NioProcessor.java (original)
+++ tomcat/trunk/java/org/apache/coyote/http11/Http11NioProcessor.java Wed Feb  1 20:11:26
2012
@@ -512,7 +512,7 @@ public class Http11NioProcessor extends 
     @Override
     protected boolean prepareSendfile(OutputFilter[] outputFilters) {
         String fileName = (String) request.getAttribute(
-                "org.apache.tomcat.sendfile.filename");
+                org.apache.coyote.Constants.SENDFILE_FILENAME_ATTR);
         if (fileName != null) {
             // No entity body sent here
             outputBuffer.addActiveFilter(outputFilters[Constants.VOID_FILTER]);
@@ -520,9 +520,9 @@ public class Http11NioProcessor extends 
             sendfileData = new NioEndpoint.SendfileData();
             sendfileData.fileName = fileName;
             sendfileData.pos = ((Long) request.getAttribute(
-                    "org.apache.tomcat.sendfile.start")).longValue();
+                    org.apache.coyote.Constants.SENDFILE_FILE_START_ATTR)).longValue();
             sendfileData.length = ((Long) request.getAttribute(
-                    "org.apache.tomcat.sendfile.end")).longValue() - sendfileData.pos;
+                    org.apache.coyote.Constants.SENDFILE_FILE_END_ATTR)).longValue() - sendfileData.pos;
             return true;
         }
         return false;



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


Mime
View raw message