tomcat-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From r...@apache.org
Subject cvs commit: jakarta-tomcat-catalina/catalina/src/share/org/apache/catalina/servlets DefaultServlet.java WebdavServlet.java
Date Fri, 03 Jan 2003 19:32:53 GMT
remm        2003/01/03 11:32:53

  Modified:    catalina/src/share/org/apache/catalina/servlets
                        DefaultServlet.java WebdavServlet.java
  Log:
  - Use the new FastHttpDateFormat.
  - Remove the remaining formatters.
  
  Revision  Changes    Path
  1.4       +22 -35    jakarta-tomcat-catalina/catalina/src/share/org/apache/catalina/servlets/DefaultServlet.java
  
  Index: DefaultServlet.java
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat-catalina/catalina/src/share/org/apache/catalina/servlets/DefaultServlet.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- DefaultServlet.java	17 Dec 2002 20:06:49 -0000	1.3
  +++ DefaultServlet.java	3 Jan 2003 19:32:52 -0000	1.4
  @@ -92,6 +92,7 @@
   import java.text.SimpleDateFormat;
   import java.security.MessageDigest;
   import java.security.NoSuchAlgorithmException;
  +
   import javax.servlet.RequestDispatcher;
   import javax.servlet.ServletException;
   import javax.servlet.ServletContext;
  @@ -99,6 +100,7 @@
   import javax.servlet.http.HttpServlet;
   import javax.servlet.http.HttpServletRequest;
   import javax.servlet.http.HttpServletResponse;
  +
   import javax.naming.NamingException;
   import javax.naming.InitialContext;
   import javax.naming.Context;
  @@ -107,10 +109,13 @@
   import javax.naming.directory.DirContext;
   import javax.naming.directory.Attribute;
   import javax.naming.directory.Attributes;
  +
  +import org.apache.tomcat.util.http.FastHttpDateFormat;
  +
   import org.apache.naming.resources.Resource;
   import org.apache.naming.resources.ResourceAttributes;
  +
   import org.apache.catalina.Globals;
  -import org.apache.catalina.util.FastHttpDateFormat;
   import org.apache.catalina.util.MD5Encoder;
   import org.apache.catalina.util.RequestUtil;
   import org.apache.catalina.util.ServerInfo;
  @@ -183,18 +188,6 @@
   
   
       /**
  -     * The set of SimpleDateFormat formats to use in getDateHeader().
  -     */
  -    protected static final SimpleDateFormat formats[] = {
  -        new SimpleDateFormat("EEE, dd MMM yyyy HH:mm:ss zzz", Locale.US),
  -        new SimpleDateFormat("EEEEEE, dd-MMM-yy HH:mm:ss zzz", Locale.US),
  -        new SimpleDateFormat("EEE MMMM d HH:mm:ss yyyy", Locale.US)
  -    };
  -
  -
  -    protected final static TimeZone gmtZone = TimeZone.getTimeZone("GMT");
  -
  -    /**
        * Array containing the safe characters set.
        */
       protected static URLEncoder urlEncoder;
  @@ -205,10 +198,6 @@
        */
       // ----------------------------------------------------- Static Initializer
       static {
  -        formats[0].setTimeZone(gmtZone);
  -        formats[1].setTimeZone(gmtZone);
  -        formats[2].setTimeZone(gmtZone);
  -
           urlEncoder = new URLEncoder();
           urlEncoder.addSafeCharacter('-');
           urlEncoder.addSafeCharacter('_');
  @@ -1216,23 +1205,20 @@
   
           // Checking If-Range
           String headerValue = request.getHeader("If-Range");
  +
           if (headerValue != null) {
   
  +            long headerValueTime = (-1L);
  +            try {
  +                headerValueTime = request.getDateHeader("If-Range");
  +            } catch (Exception e) {
  +                ;
  +            }
  +
               String eTag = getETag(resourceInfo);
               long lastModified = resourceInfo.date;
   
  -            Date date = null;
  -
  -            // Parsing the HTTP Date
  -            for (int i = 0; (date == null) && (i < formats.length); i++) {
  -                try {
  -                    date = formats[i].parse(headerValue);
  -                } catch (ParseException e) {
  -                    ;
  -                }
  -            }
  -
  -            if (date == null) {
  +            if (headerValueTime == (-1L)) {
   
                   // If the ETag the client gave does not match the entity
                   // etag, then the entire entity is returned.
  @@ -1244,7 +1230,7 @@
                   // If the timestamp of the entity the client got is older than
                   // the last modification date of the entity, the entire entity
                   // is returned.
  -                if (lastModified > (date.getTime() + 1000))
  +                if (lastModified > (headerValueTime + 1000))
                       return null;
   
               }
  @@ -2289,8 +2275,9 @@
                               creationDate = tempDate.getTime();
                           tempDate = tempAttrs.getLastModifiedDate();
                           if (tempDate != null) {
  -                            httpDate = FastHttpDateFormat.getDate(tempDate);
                               date = tempDate.getTime();
  +                            httpDate = 
  +                                FastHttpDateFormat.formatDate(date, null);
                           } else {
                               httpDate = FastHttpDateFormat.getCurrentDate();
                           }
  
  
  
  1.3       +21 -11    jakarta-tomcat-catalina/catalina/src/share/org/apache/catalina/servlets/WebdavServlet.java
  
  Index: WebdavServlet.java
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat-catalina/catalina/src/share/org/apache/catalina/servlets/WebdavServlet.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- WebdavServlet.java	13 Aug 2002 20:45:02 -0000	1.2
  +++ WebdavServlet.java	3 Jan 2003 19:32:52 -0000	1.3
  @@ -89,11 +89,13 @@
   import java.text.SimpleDateFormat;
   import java.security.MessageDigest;
   import java.security.NoSuchAlgorithmException;
  +
   import org.w3c.dom.Node;
   import org.w3c.dom.NodeList;
   import org.w3c.dom.Element;
   import org.w3c.dom.Document;
   import org.xml.sax.InputSource;
  +
   import javax.servlet.RequestDispatcher;
   import javax.servlet.ServletException;
   import javax.servlet.ServletContext;
  @@ -101,9 +103,11 @@
   import javax.servlet.http.HttpServlet;
   import javax.servlet.http.HttpServletRequest;
   import javax.servlet.http.HttpServletResponse;
  +
   import javax.xml.parsers.DocumentBuilder;
   import javax.xml.parsers.DocumentBuilderFactory;
   import javax.xml.parsers.ParserConfigurationException;
  +
   import javax.naming.NamingException;
   import javax.naming.InitialContext;
   import javax.naming.Context;
  @@ -112,8 +116,12 @@
   import javax.naming.directory.DirContext;
   import javax.naming.directory.Attribute;
   import javax.naming.directory.Attributes;
  +
  +import org.apache.tomcat.util.http.FastHttpDateFormat;
  +
   import org.apache.naming.resources.Resource;
   import org.apache.naming.resources.ResourceAttributes;
  +
   import org.apache.catalina.util.MD5Encoder;
   import org.apache.catalina.util.StringManager;
   import org.apache.catalina.util.XMLWriter;
  @@ -2329,7 +2337,8 @@
               generatedXML.writeProperty(null, "getcontentlanguage",
                                          Locale.getDefault().toString());
               generatedXML.writeProperty(null, "getlastmodified",
  -                                       formats[0].format(lock.creationDate));
  +                                       FastHttpDateFormat.formatDate
  +                                       (lock.creationDate.getTime(), null));
               generatedXML.writeProperty
                   (null, "getcontentlength", String.valueOf(0));
               generatedXML.writeProperty(null, "getcontenttype", "");
  @@ -2439,7 +2448,8 @@
                   } else if (property.equals("getlastmodified")) {
                       generatedXML.writeProperty
                           (null, "getlastmodified",
  -                         formats[0].format(lock.creationDate));
  +                          FastHttpDateFormat.formatDate
  +                         (lock.creationDate.getTime(), null));
                   } else if (property.equals("resourcetype")) {
                       generatedXML.writeElement(null, "resourcetype",
                                                 XMLWriter.OPENING);
  @@ -2633,8 +2643,8 @@
               result += "Scope:" + scope + "\n";
               result += "Depth:" + depth + "\n";
               result += "Owner:" + owner + "\n";
  -            result += "Expiration:" +
  -                formats[0].format(new Date(expiresAt)) + "\n";
  +            result += "Expiration:" 
  +                + FastHttpDateFormat.formatDate(expiresAt, null) + "\n";
               Enumeration tokensList = tokens.elements();
               while (tokensList.hasMoreElements()) {
                   result += "Token:" + tokensList.nextElement() + "\n";
  @@ -2815,8 +2825,8 @@
        * moved to another location, but that future references should
        * still use the original URI to access the resource.
        */
  -    public static final int SC_FOUND =
  -        HttpServletResponse.SC_FOUND;
  +    public static final int SC_MOVED_TEMPORARILY =
  +        HttpServletResponse.SC_MOVED_TEMPORARILY;
   
   
       /**
  @@ -2998,7 +3008,7 @@
           addStatusCodeMap(SC_ACCEPTED, "Accepted");
           addStatusCodeMap(SC_NO_CONTENT, "No Content");
           addStatusCodeMap(SC_MOVED_PERMANENTLY, "Moved Permanently");
  -        addStatusCodeMap(SC_FOUND, "Moved Temporarily");
  +        addStatusCodeMap(SC_MOVED_TEMPORARILY, "Moved Temporarily");
           addStatusCodeMap(SC_NOT_MODIFIED, "Not Modified");
           addStatusCodeMap(SC_BAD_REQUEST, "Bad Request");
           addStatusCodeMap(SC_UNAUTHORIZED, "Unauthorized");
  
  
  

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


Mime
View raw message