tomcat-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From lu...@apache.org
Subject cvs commit: jakarta-tomcat-catalina/catalina/src/share/org/apache/catalina/util DateTool.java
Date Wed, 13 Aug 2003 00:13:54 GMT
luehe       2003/08/12 17:13:54

  Modified:    catalina/src/share/org/apache/catalina/authenticator
                        AuthenticatorBase.java
               catalina/src/share/org/apache/catalina/util DateTool.java
  Log:
  Optimizations:
  
  - Bugtraq 4730584 ("HttpResponseBase should create date format only
    when needed")
  
  - Bugtraq 4701695 ("avoid reformatting constant Expires header on every
    request")
  
  Revision  Changes    Path
  1.10      +17 -5     jakarta-tomcat-catalina/catalina/src/share/org/apache/catalina/authenticator/AuthenticatorBase.java
  
  Index: AuthenticatorBase.java
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat-catalina/catalina/src/share/org/apache/catalina/authenticator/AuthenticatorBase.java,v
  retrieving revision 1.9
  retrieving revision 1.10
  diff -u -r1.9 -r1.10
  --- AuthenticatorBase.java	25 Jul 2003 05:06:49 -0000	1.9
  +++ AuthenticatorBase.java	13 Aug 2003 00:13:54 -0000	1.10
  @@ -72,6 +72,9 @@
   import java.security.MessageDigest;
   import java.security.NoSuchAlgorithmException;
   import java.security.Principal;
  +import java.text.SimpleDateFormat;
  +import java.util.Date;
  +import java.util.Locale;
   import java.util.Random;
   import java.util.List;
   import java.util.Iterator;
  @@ -103,6 +106,7 @@
   import org.apache.catalina.util.LifecycleSupport;
   import org.apache.catalina.util.RequestUtil;
   import org.apache.catalina.util.StringManager;
  +import org.apache.catalina.util.DateTool;
   import org.apache.catalina.valves.ValveBase;
   import org.apache.commons.logging.Log;
   import org.apache.commons.logging.LogFactory;
  @@ -244,6 +248,14 @@
       protected boolean started = false;
   
   
  +    /**
  +     * "Expires" header always set to Date(1), so generate once only
  +     */
  +    private static final String DATE_ONE =
  +        (new SimpleDateFormat(DateTool.HTTP_RESPONSE_DATE_HEADER,
  +                              Locale.US)).format(new Date(1));
  +
  +
       // ------------------------------------------------------------- Properties
   
   
  @@ -512,7 +524,7 @@
                   (HttpServletResponse) response.getResponse();
               sresponse.setHeader("Pragma", "No-cache");
               sresponse.setHeader("Cache-Control", "no-cache");
  -            sresponse.setDateHeader("Expires", 1);
  +            sresponse.setHeader("Expires", DATE_ONE);
           }
   	int i;
   	for(i=0; i < constraints.length; i++) {
  
  
  
  1.2       +21 -9     jakarta-tomcat-catalina/catalina/src/share/org/apache/catalina/util/DateTool.java
  
  Index: DateTool.java
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat-catalina/catalina/src/share/org/apache/catalina/util/DateTool.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- DateTool.java	18 Jul 2002 16:47:45 -0000	1.1
  +++ DateTool.java	13 Aug 2003 00:13:54 -0000	1.2
  @@ -82,19 +82,28 @@
       private static StringManager sm =
           StringManager.getManager("org.apache.catalina.util");
   
  -    /** US locale - all HTTP dates are in english
  +    /**
  +     * US locale - all HTTP dates are in english
        */
       public final static Locale LOCALE_US = Locale.US;
   
  -    /** GMT timezone - all HTTP dates are on GMT
  +    /**
  +     * GMT timezone - all HTTP dates are on GMT
        */
       public final static TimeZone GMT_ZONE = TimeZone.getTimeZone("GMT");
   
  -    /** format for RFC 1123 date string -- "Sun, 06 Nov 1994 08:49:37 GMT"
  +    /**
  +     * format for RFC 1123 date string -- "Sun, 06 Nov 1994 08:49:37 GMT"
        */
       public final static String RFC1123_PATTERN =
           "EEE, dd MMM yyyyy HH:mm:ss z";
   
  +    /** 
  +     * Format for http response header date field
  +     */
  +    public static final String HTTP_RESPONSE_DATE_HEADER =
  +        "EEE, dd MMM yyyy HH:mm:ss zzz";
  +
       // format for RFC 1036 date string -- "Sunday, 06-Nov-94 08:49:37 GMT"
       private final static String rfc1036Pattern =
           "EEEEEEEEE, dd-MMM-yy HH:mm:ss z";
  @@ -103,16 +112,19 @@
       private final static String asctimePattern =
           "EEE MMM d HH:mm:ss yyyyy";
   
  -    /** Pattern used for old cookies
  +    /**
  +     * Pattern used for old cookies
        */
       public final static String OLD_COOKIE_PATTERN = "EEE, dd-MMM-yyyy HH:mm:ss z";
   
  -    /** DateFormat to be used to format dates
  +    /**
  +     * DateFormat to be used to format dates
        */
       public final static DateFormat rfc1123Format =
           new SimpleDateFormat(RFC1123_PATTERN, LOCALE_US);
   
  -    /** DateFormat to be used to format old netscape cookies
  +    /**
  +     * DateFormat to be used to format old netscape cookies
        */
       public final static DateFormat oldCookieFormat =
           new SimpleDateFormat(OLD_COOKIE_PATTERN, LOCALE_US);
  
  
  

Mime
View raw message