costin      00/11/30 14:43:56

  Modified:    .        changes3.3
               src/facade22/org/apache/tomcat/facade CookieFacade.java
                        HttpServletRequestFacade.java
                        HttpServletResponseFacade.java
               src/share/org/apache/tomcat/core Request.java
               src/share/org/apache/tomcat/helper CookieTools.java
               src/share/org/apache/tomcat/modules/session SessionId.java
               src/share/org/apache/tomcat/util/http Cookies.java
                        ServerCookie.java
  Removed:     src/share/org/apache/tomcat/util ServerCookie.java
  Log:
  Removed the old ServerCookie and 1/2 of CookieTools.
  
  Revision  Changes    Path
  1.2       +22 -3     jakarta-tomcat/changes3.3
  
  Index: changes3.3
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat/changes3.3,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- changes3.3        2000/11/30 08:19:10     1.1
  +++ changes3.3        2000/11/30 22:43:43     1.2
  @@ -134,8 +134,6 @@
   
   - better integration for form login with apache
   
  -- This is the living To-Do list for Tomcat 3.3
  -
   - Optimize error handling. For example, we can use int IDs for error 
   messages ( needs enhancements in StringManager ) 
   - Cache the error page handler ( instead of doing a second mapping 
  @@ -153,5 +151,26 @@
   - Merge HTTP1.1 code from catalina
   
   - Merge JMX code from catalina
  +
  +- Merge JNDI code from catalina
  +
  +- Experiment and implement "sendFile" for chunks of static JSP, cache the
  +static region as byte[] on the server ( integrated mode )
  +
  +- Fix mod_jk for Apache2.0 !!!
  +
  +- Add callbacks to mod_jk, integrate authentication ( user Apache's user db)
  +
  +- Experiment with mixed applications, integrate the session and auth 
  +representation of mod_perl and php
  +
  +- Implement the profiling web app ( that allows you to get a profile of a 
  +servlet container, how expensive is each API call )
  +
  +- Expose more internals via /admin ( number of threads, memory, etc)
  +
  +- Experiment with Apache2.0 config ( and IIS ? ), try to integrate
  +
  +- Make sure the  request parsed by Apache is not parsed again.
   
  -- Merge JNDI code from catalina
  \ No newline at end of file
  +- Interceptor == Module == SAF ( will this ever happen ?)
  
  
  
  1.4       +1 -0      
jakarta-tomcat/src/facade22/org/apache/tomcat/facade/CookieFacade.java
  
  Index: CookieFacade.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-tomcat/src/facade22/org/apache/tomcat/facade/CookieFacade.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- CookieFacade.java 2000/10/27 20:50:49     1.3
  +++ CookieFacade.java 2000/11/30 22:43:46     1.4
  @@ -61,6 +61,7 @@
   package org.apache.tomcat.facade;
   
   import org.apache.tomcat.util.*;
  +import org.apache.tomcat.util.http.*;
   import org.apache.tomcat.helper.RequestUtil;
   import org.apache.tomcat.core.*;
   import org.apache.tomcat.facade.*;
  
  
  
  1.10      +1 -0      
jakarta-tomcat/src/facade22/org/apache/tomcat/facade/HttpServletRequestFacade.java
  
  Index: HttpServletRequestFacade.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-tomcat/src/facade22/org/apache/tomcat/facade/HttpServletRequestFacade.java,v
  retrieving revision 1.9
  retrieving revision 1.10
  diff -u -r1.9 -r1.10
  --- HttpServletRequestFacade.java     2000/11/30 04:58:36     1.9
  +++ HttpServletRequestFacade.java     2000/11/30 22:43:46     1.10
  @@ -61,6 +61,7 @@
   package org.apache.tomcat.facade;
   
   import org.apache.tomcat.util.*;
  +import org.apache.tomcat.util.http.*;
   import org.apache.tomcat.helper.RequestUtil;
   import org.apache.tomcat.core.*;
   import org.apache.tomcat.facade.*;
  
  
  
  1.12      +3 -13     
jakarta-tomcat/src/facade22/org/apache/tomcat/facade/HttpServletResponseFacade.java
  
  Index: HttpServletResponseFacade.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-tomcat/src/facade22/org/apache/tomcat/facade/HttpServletResponseFacade.java,v
  retrieving revision 1.11
  retrieving revision 1.12
  diff -u -r1.11 -r1.12
  --- HttpServletResponseFacade.java    2000/11/30 07:59:03     1.11
  +++ HttpServletResponseFacade.java    2000/11/30 22:43:46     1.12
  @@ -61,6 +61,7 @@
   package org.apache.tomcat.facade;
   
   import org.apache.tomcat.util.*;
  +import org.apache.tomcat.util.http.*;
   import org.apache.tomcat.core.*;
   import org.apache.tomcat.helper.*;
   import java.io.*;
  @@ -113,19 +114,8 @@
        // frequent operation ( for example sc can be reused )
        ServerCookie sc=new ServerCookie();
        cookie2serverCookie( cookie, sc);
  -     addHeader( CookieTools.getCookieHeaderName(cookie.getVersion()),
  -                CookieTools.getCookieHeaderValue(sc));
  -     // This shouldn't be done - if the user asks for a specific
  -     // version, only that version should be set !!!
  -//   if( cookie.getVersion() == 1 ) {
  -//       // sc is not reused
  -//       sc.setVersion(0);
  -//       addHeader( CookieTools.getCookieHeaderName(sc.getVersion()),
  -//                  CookieTools.getCookieHeaderValue(sc));
  -//   }
  -     // Is it needed ? ( result of refactoring, that's how the code
  -     // worked) 
  -     //response.addUserCookie(cookie);
  +     addHeader( sc.getCookieHeaderName(),
  +                sc.getCookieHeaderValue());
       }
   
       public boolean containsHeader(String name) {
  
  
  
  1.76      +1 -0      jakarta-tomcat/src/share/org/apache/tomcat/core/Request.java
  
  Index: Request.java
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat/src/share/org/apache/tomcat/core/Request.java,v
  retrieving revision 1.75
  retrieving revision 1.76
  diff -u -r1.75 -r1.76
  --- Request.java      2000/11/30 07:59:04     1.75
  +++ Request.java      2000/11/30 22:43:48     1.76
  @@ -61,6 +61,7 @@
   package org.apache.tomcat.core;
   
   import org.apache.tomcat.util.*;
  +import org.apache.tomcat.util.http.*;
   import org.apache.tomcat.helper.*;
   import org.apache.tomcat.session.ServerSession;
   import java.io.IOException;
  
  
  
  1.7       +109 -108  
jakarta-tomcat/src/share/org/apache/tomcat/helper/CookieTools.java
  
  Index: CookieTools.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-tomcat/src/share/org/apache/tomcat/helper/CookieTools.java,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- CookieTools.java  2000/11/20 02:09:01     1.6
  +++ CookieTools.java  2000/11/30 22:43:50     1.7
  @@ -59,6 +59,7 @@
   
   package org.apache.tomcat.helper;
   import  org.apache.tomcat.util.*;
  +import  org.apache.tomcat.util.http.*;
   import  org.apache.tomcat.core.*;
   import  org.apache.tomcat.session.*;
   import java.text.*;
  @@ -157,114 +158,114 @@
       }  
       
       
  -    /** Return the header name to set the cookie, based on cookie
  -     *  version
  -     */
  -    public static String getCookieHeaderName(int version) {
  -        if (version == 1) {
  -         return "Set-Cookie2";
  -        } else {
  -            return "Set-Cookie";
  -        }
  -    }
  -
  -    /** Return the header value used to set this cookie
  -     *  @deprecated Use StringBuffer version
  -     */
  -    public static String getCookieHeaderValue(ServerCookie cookie) {
  -        StringBuffer buf = new StringBuffer();
  -     getCookieHeaderValue( cookie, buf );
  -     return buf.toString();
  -    }
  -
  -    /** Return the header value used to set this cookie
  -     */
  -    public static void getCookieHeaderValue(ServerCookie cookie,
  -                                         StringBuffer buf) {
  -        int version = cookie.getVersion();
  -
  -        // this part is the same for all cookies
  -
  -        buf.append(cookie.getName());
  -        buf.append("=");
  -        maybeQuote(version, buf, cookie.getValue().toString());
  -
  -     // add version 1 specific information
  -     if (version == 1) {
  -         // Version=1 ... required
  -         buf.append ("; Version=1");
  -
  -         // Comment=comment
  -         if (cookie.getComment() != null) {
  -             buf.append ("; Comment=");
  -             maybeQuote (version, buf, cookie.getComment().toString());
  -         }
  -     }
  -
  -     // add domain information, if present
  -
  -     if (!cookie.getDomain().isNull()) {
  -         buf.append("; Domain=");
  -         maybeQuote (version, buf, cookie.getDomain().toString());
  -     }
  -
  -     // Max-Age=secs/Discard ... or use old "Expires" format
  -     if (cookie.getMaxAge() >= 0) {
  -         if (version == 0) {
  -             buf.append ("; Expires=");
  -             DateTool.oldCookieFormat.format(new Date( System.currentTimeMillis() + 
cookie.getMaxAge() *1000L) ,buf,
  -                                             new FieldPosition(0));
  -
  -         } else {
  -             buf.append ("; Max-Age=");
  -             buf.append (cookie.getMaxAge());
  -         }
  -     } else if (version == 1)
  -       buf.append ("; Discard");
  -
  -     // Path=path
  -     if (! cookie.getPath().isNull()) {
  -         buf.append ("; Path=");
  -         maybeQuote (version, buf, cookie.getPath().toString());
  -     }
  -
  -     // Secure
  -     if (cookie.getSecure()) {
  -       buf.append ("; Secure");
  -     }
  -    }
  -
  -    public static void maybeQuote (int version, StringBuffer buf,
  -                                    String value)
  -    {
  -     if (version == 0 || isToken (value))
  -       buf.append (value);
  -     else {
  -         buf.append ('"');
  -         buf.append (value);
  -         buf.append ('"');
  -     }
  -    }
  -
  -        //
  -    // from RFC 2068, token special case characters
  -    //
  -    private static final String tspecials = "()<>@,;:\\\"/[]?={} \t";
  -
  -    /*
  -     * Return true iff the string counts as an HTTP/1.1 "token".
  -     */
  -    private static boolean isToken (String value) {
  -     int len = value.length ();
  -
  -     for (int i = 0; i < len; i++) {
  -         char c = value.charAt (i);
  -
  -         if (c < 0x20 || c >= 0x7f || tspecials.indexOf (c) != -1)
  -           return false;
  -     }
  -     return true;
  -    }
  +//     /** Return the header name to set the cookie, based on cookie
  +//      *  version
  +//      */
  +//     public static String getCookieHeaderName(int version) {
  +//         if (version == 1) {
  +//       return "Set-Cookie2";
  +//         } else {
  +//             return "Set-Cookie";
  +//         }
  +//     }
  +
  +//     /** Return the header value used to set this cookie
  +//      *  @deprecated Use StringBuffer version
  +//      */
  +//     public static String getCookieHeaderValue(ServerCookie cookie) {
  +//         StringBuffer buf = new StringBuffer();
  +//   getCookieHeaderValue( cookie, buf );
  +//   return buf.toString();
  +//     }
  +
  +//     /** Return the header value used to set this cookie
  +//      */
  +//     public static void getCookieHeaderValue(ServerCookie cookie,
  +//                                       StringBuffer buf) {
  +//         int version = cookie.getVersion();
  +
  +//         // this part is the same for all cookies
  +
  +//         buf.append(cookie.getName());
  +//         buf.append("=");
  +//         maybeQuote(version, buf, cookie.getValue().toString());
  +
  +//   // add version 1 specific information
  +//   if (version == 1) {
  +//       // Version=1 ... required
  +//       buf.append ("; Version=1");
  +
  +//       // Comment=comment
  +//       if (cookie.getComment() != null) {
  +//           buf.append ("; Comment=");
  +//           maybeQuote (version, buf, cookie.getComment().toString());
  +//       }
  +//   }
  +
  +//   // add domain information, if present
  +
  +//   if (!cookie.getDomain().isNull()) {
  +//       buf.append("; Domain=");
  +//       maybeQuote (version, buf, cookie.getDomain().toString());
  +//   }
  +
  +//   // Max-Age=secs/Discard ... or use old "Expires" format
  +//   if (cookie.getMaxAge() >= 0) {
  +//       if (version == 0) {
  +//           buf.append ("; Expires=");
  +//           DateTool.oldCookieFormat.format(new Date( System.currentTimeMillis() + 
cookie.getMaxAge() *1000L) ,buf,
  +//                                           new FieldPosition(0));
  +
  +//       } else {
  +//           buf.append ("; Max-Age=");
  +//           buf.append (cookie.getMaxAge());
  +//       }
  +//   } else if (version == 1)
  +//     buf.append ("; Discard");
  +
  +//   // Path=path
  +//   if (! cookie.getPath().isNull()) {
  +//       buf.append ("; Path=");
  +//       maybeQuote (version, buf, cookie.getPath().toString());
  +//   }
  +
  +//   // Secure
  +//   if (cookie.getSecure()) {
  +//     buf.append ("; Secure");
  +//   }
  +//     }
  +
  +//     public static void maybeQuote (int version, StringBuffer buf,
  +//                                     String value)
  +//     {
  +//   if (version == 0 || isToken (value))
  +//     buf.append (value);
  +//   else {
  +//       buf.append ('"');
  +//       buf.append (value);
  +//       buf.append ('"');
  +//   }
  +//     }
  +
  +//         //
  +//     // from RFC 2068, token special case characters
  +//     //
  +//     private static final String tspecials = "()<>@,;:\\\"/[]?={} \t";
  +
  +//     /*
  +//      * Return true iff the string counts as an HTTP/1.1 "token".
  +//      */
  +//     private static boolean isToken (String value) {
  +//   int len = value.length ();
  +
  +//   for (int i = 0; i < len; i++) {
  +//       char c = value.charAt (i);
  +
  +//       if (c < 0x20 || c >= 0x7f || tspecials.indexOf (c) != -1)
  +//         return false;
  +//   }
  +//   return true;
  +//     }
   
   
   }
  
  
  
  1.3       +2 -1      
jakarta-tomcat/src/share/org/apache/tomcat/modules/session/SessionId.java
  
  Index: SessionId.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-tomcat/src/share/org/apache/tomcat/modules/session/SessionId.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- SessionId.java    2000/11/22 00:09:59     1.2
  +++ SessionId.java    2000/11/30 22:43:53     1.3
  @@ -61,6 +61,7 @@
   
   import org.apache.tomcat.core.*;
   import org.apache.tomcat.util.*;
  +import org.apache.tomcat.util.http.*;
   import org.apache.tomcat.helper.*;
   import org.apache.tomcat.session.ServerSessionManager;
   import org.apache.tomcat.session.ServerSession;
  @@ -245,7 +246,7 @@
        buf.append( "JSESSIONID=" ).append( reqSessionId );
        buf.append( ";Version=1" );
        buf.append( ";Path=" );
  -     CookieTools.maybeQuote( 1 , buf, sessionPath ); // XXX ugly 
  +     ServerCookie.maybeQuote( 1 , buf, sessionPath ); // XXX ugly 
        buf.append( ";Discard" );
        // discard results from:        cookie.setMaxAge(-1);
        
  
  
  
  1.2       +23 -14    
jakarta-tomcat/src/share/org/apache/tomcat/util/http/Cookies.java
  
  Index: Cookies.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-tomcat/src/share/org/apache/tomcat/util/http/Cookies.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- Cookies.java      2000/11/30 17:42:49     1.1
  +++ Cookies.java      2000/11/30 22:43:55     1.2
  @@ -62,7 +62,6 @@
   import org.apache.tomcat.util.collections.*;
   import org.apache.tomcat.util.MessageBytes;
   import org.apache.tomcat.util.MimeHeaders;
  -import org.apache.tomcat.util.ServerCookie;
   import org.apache.tomcat.util.DateTool;
   
   import java.io.*;
  @@ -71,6 +70,7 @@
   
   /**
    * A collection of cookies - reusable and tuned for server side performance.
  + * Based on RFC2965 ( and 2109 )
    * 
    * @author Costin Manolache
    */
  @@ -139,19 +139,22 @@
        // process each "cookie" header
        int pos=0;
        while( pos>=0 ) {
  +         // Cookie2: version ? not needed
            pos=headers.findHeader( "Cookie", pos );
            // no more cookie headers headers
            if( pos<0 ) break;
   
            MessageBytes cookieValue=headers.getValue( pos );
            if( cookieValue==null || cookieValue.isNull() ) continue;
  -         if( cookieValue.getType() == MessageBytes.T_BYTES ) {
  -             processCookieHeader( cookieValue.getBytes(),
  -                                  cookieValue.getOffset(),
  -                                  cookieValue.getLength());
  -         } else {
  -             processCookieHeader( cookieValue.toString() );
  -         }
  +
  +         // Uncomment to test the new parsing code
  +         //      if( cookieValue.getType() == MessageBytes.T_BYTES ) {
  +         //          processCookieHeader( cookieValue.getBytes(),
  +         //                               cookieValue.getOffset(),
  +         //                               cookieValue.getLength());
  +         //      } else {
  +         processCookieHeader( cookieValue.toString() );
  +         //      }
        }
       }
   
  @@ -167,14 +170,19 @@
            int startName=skipSpaces(bytes, pos, end);
            if( pos>=end )
                return; // only spaces
  -         
  +
  +         // Version should be the first token
            boolean isSpecial=false;
            if(bytes[pos]=='$') { pos++; isSpecial=true; }
  -         
  +
            int endName= findDelim1( bytes, startName, end); // " =;,"
  -         if(endName >= end )
  -             return; // invalid
  -     
  +         if(endName >= end ) {
  +             // it's a name-only cookie ( valid in RFC2109 )
  +             // XXX todo
  +             return; 
  +         }
  +         // XXX it's a , or a ; ?
  +         
            // current = "=" or " " 
            pos= skipSpaces( bytes, endName, end );
            if(endName >= end )
  @@ -198,6 +206,7 @@
            pos++;
            int startValue=skipSpaces( bytes, pos, end);
            int endValue=startValue;
  +         // XXX quote is valid only in version=1 cookies
            if( bytes[pos]== '\'' || bytes[pos]=='"' ) {
                startValue++;
                endValue=indexOf( bytes, startValue, end, bytes[startValue] );
  @@ -212,7 +221,7 @@
                sc.getValue().setBytes( bytes, startValue, endValue );
                continue;
            }
  -         // special - Path, Version, Domain
  +         // special - Path, Version, Domain, Port
            // XXX TODO
        }
       }
  
  
  
  1.2       +17 -2     
jakarta-tomcat/src/share/org/apache/tomcat/util/http/ServerCookie.java
  
  Index: ServerCookie.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-tomcat/src/share/org/apache/tomcat/util/http/ServerCookie.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- ServerCookie.java 2000/11/30 17:42:49     1.1
  +++ ServerCookie.java 2000/11/30 22:43:55     1.2
  @@ -79,11 +79,13 @@
   
       private int maxAge = -1; // ;Max-Age=VALUE
                                // ;Discard ... implied by maxAge < 0
  +    // RFC2109: maxAge=0 will end a session
       private MessageBytes path=new MessageBytes();    // ;Path=VALUE .
       private boolean secure;  // ;Secure
       private int version = 0; // ;Version=1
   
  -
  +    //XXX CommentURL, Port -> use notes ?
  +    
       public ServerCookie() {
   
       }
  @@ -200,10 +202,19 @@
        *  version
        */
       public String getCookieHeaderName() {
  +     return getCookieHeaderName(version);
  +    }
  +
  +    /** Return the header name to set the cookie, based on cookie
  +     *  version
  +     */
  +    public static String getCookieHeaderName(int version) {
           if (version == 1) {
  +         // RFC2965
            return "Set-Cookie2";
           } else {
  -            return "Set-Cookie";
  +         // Old Netscape
  +         return "Set-Cookie";
           }
       }
   
  @@ -226,6 +237,7 @@
           buf.append("=");
           maybeQuote(version, buf, cookie.getValue().toString());
   
  +     // XXX Netscape cookie: "; "
        // add version 1 specific information
        if (version == 1) {
            // Version=1 ... required
  @@ -248,7 +260,10 @@
        // Max-Age=secs/Discard ... or use old "Expires" format
        if (cookie.getMaxAge() >= 0) {
            if (version == 0) {
  +             // XXX XXX XXX We need to send both, for
  +             // interoperatibility (long word )
                buf.append (";Expires=");
  +             // Wdy, DD-Mon-YY HH:MM:SS GMT ( Expires netscape format )
                DateTool.oldCookieFormat.
                    format(new Date( System.currentTimeMillis() +
                                     cookie.getMaxAge() *1000L) ,buf,
  
  
  

Reply via email to