olegk       2003/02/04 13:22:07

  Modified:    httpclient/src/java/org/apache/commons/httpclient
                        Cookie.java
  Log:
  - Cookie#Cookie(String, String, String, String, int, boolean) constructor corrected 
to accept -1 MaxAge value (cookie never expires)
  
  Contributed by Oleg Kalnichevski
  
  Revision  Changes    Path
  1.38      +12 -8     
jakarta-commons/httpclient/src/java/org/apache/commons/httpclient/Cookie.java
  
  Index: Cookie.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-commons/httpclient/src/java/org/apache/commons/httpclient/Cookie.java,v
  retrieving revision 1.37
  retrieving revision 1.38
  diff -u -r1.37 -r1.38
  --- Cookie.java       4 Feb 2003 20:16:24 -0000       1.37
  +++ Cookie.java       4 Feb 2003 21:22:07 -0000       1.38
  @@ -160,7 +160,9 @@
        * @param value  the cookie value
        * @param domain the host this cookie will be sent to
        * @param path   the path prefix for which this cookie will be sent
  -     * @param maxAge the number of seconds for which this cookie is valid
  +     * @param maxAge the number of seconds for which this cookie is valid.
  +     *               maxAge is expected to be a non-negative number. 
  +     *               <tt>-1</tt> signifies that the cookie should never expire.
        * @param secure if <tt>true</tt> this cookie will only be sent over secure
        * connections
        */
  @@ -168,10 +170,12 @@
           int maxAge, boolean secure) {
               
           this(domain, name, value, path, null, secure);
  -        if (maxAge < 0) {
  -            throw new IllegalArgumentException("Max age name may not be negative");
  +        if (maxAge < -1) {
  +            throw new IllegalArgumentException("Invalid max age:  " + 
Integer.toString(maxAge));
           }            
  -        setExpiryDate(new Date(System.currentTimeMillis() + maxAge * 1000L));
  +        if (maxAge >= 0) {
  +            setExpiryDate(new Date(System.currentTimeMillis() + maxAge * 1000L));
  +        }
       }
   
       /**
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to