mbecke      2003/11/02 10:18:30

  Modified:    httpclient/src/java/org/apache/commons/httpclient/cookie
                        CookieSpecBase.java CookiePolicy.java
               httpclient/src/test/org/apache/commons/httpclient
                        TestCookie.java
               httpclient release_notes.txt
  Added:       httpclient/src/java/org/apache/commons/httpclient/cookie
                        IgnoreCookiesSpec.java
  Log:
  Adds IgnoreCookiesSpec.
  
  PR: 24012
  Submitted by: Michael Becke
  Reviewed by: Oleg Kalnichevski
  
  Revision  Changes    Path
  1.20      +4 -4      
jakarta-commons/httpclient/src/java/org/apache/commons/httpclient/cookie/CookieSpecBase.java
  
  Index: CookieSpecBase.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-commons/httpclient/src/java/org/apache/commons/httpclient/cookie/CookieSpecBase.java,v
  retrieving revision 1.19
  retrieving revision 1.20
  diff -u -r1.19 -r1.20
  --- CookieSpecBase.java       20 Oct 2003 22:26:28 -0000      1.19
  +++ CookieSpecBase.java       2 Nov 2003 18:18:30 -0000       1.20
  @@ -638,7 +638,7 @@
           String s = cookie.getValue();
           if (s != null) {
               buf.append(s);
  -        };
  +        }
           return buf.toString();
       }
   
  
  
  
  1.10      +9 -3      
jakarta-commons/httpclient/src/java/org/apache/commons/httpclient/cookie/CookiePolicy.java
  
  Index: CookiePolicy.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-commons/httpclient/src/java/org/apache/commons/httpclient/cookie/CookiePolicy.java,v
  retrieving revision 1.9
  retrieving revision 1.10
  diff -u -r1.9 -r1.10
  --- CookiePolicy.java 20 Oct 2003 22:17:12 -0000      1.9
  +++ CookiePolicy.java 2 Nov 2003 18:18:30 -0000       1.10
  @@ -109,6 +109,11 @@
       public static final String RFC_2109 = "rfc2109";
       
       /** 
  +     * The policy that ignores cookies. 
  +     */
  +    public static final String IGNORE_COOKIES = "ignoreCookies";
  +    
  +    /** 
        * The default cookie policy. 
        */
       public static final String DEFAULT = "default";
  @@ -118,6 +123,7 @@
           CookiePolicy.registerCookieSpec(RFC_2109, new RFC2109Spec());
           CookiePolicy.registerCookieSpec(BROWSER_COMPATIBILITY, new 
CookieSpecBase());
           CookiePolicy.registerCookieSpec(NETSCAPE, new NetscapeDraftSpec());
  +        CookiePolicy.registerCookieSpec(IGNORE_COOKIES, new IgnoreCookiesSpec());
       }
       
       /**
  
  
  
  1.1                  
jakarta-commons/httpclient/src/java/org/apache/commons/httpclient/cookie/IgnoreCookiesSpec.java
  
  Index: IgnoreCookiesSpec.java
  ===================================================================
  /*
   * $Header: 
/home/cvs/jakarta-commons/httpclient/src/java/org/apache/commons/httpclient/cookie/IgnoreCookiesSpec.java,v
 1.1 2003/11/02 18:18:30 mbecke Exp $
   * $Revision: 1.1 $
   * $Date: 2003/11/02 18:18:30 $
   *
   * ====================================================================
   *
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 2002-2003 The Apache Software Foundation.  All rights
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer.
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution, if
   *    any, must include the following acknowlegement:
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowlegement may appear in the software itself,
   *    if and wherever such third-party acknowlegements normally appear.
   *
   * 4. The names "The Jakarta Project", "Commons", and "Apache Software
   *    Foundation" must not be used to endorse or promote products derived
   *    from this software without prior written permission. For written
   *    permission, please contact [EMAIL PROTECTED]
   *
   * 5. Products derived from this software may not be called "Apache"
   *    nor may "Apache" appear in their names without prior written
   *    permission of the Apache Group.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   *
   * [Additional notices, if required by prior licensing conditions]
   *
   */ 
  
  package org.apache.commons.httpclient.cookie;
  
  import org.apache.commons.httpclient.Cookie;
  import org.apache.commons.httpclient.Header;
  import org.apache.commons.httpclient.NameValuePair;
  
  /**
   * A cookie spec that does nothing.  Cookies are neither parsed, formatted nor 
matched.
   * 
   * @since 2.1
   */
  public class IgnoreCookiesSpec implements CookieSpec {
  
      /**
       * 
       */
      public IgnoreCookiesSpec() {
          super();
      }
  
      /**
       * Returns an empty [EMAIL PROTECTED] Cookie cookie} array.  All parameters are 
ignored.
       */
      public Cookie[] parse(String host, int port, String path, boolean secure, String 
header)
          throws MalformedCookieException {
          return new Cookie[0];
      }
  
      /**
       * @return <code>null</code>
       */
      public String formatCookie(Cookie cookie) {
          return null;
      }
  
      /**
       * @return <code>null</code>
       */
      public Header formatCookieHeader(Cookie cookie) throws IllegalArgumentException {
          return null;
      }
  
      /**
       * @return <code>null</code>
       */
      public Header formatCookieHeader(Cookie[] cookies) throws 
IllegalArgumentException {
          return null;
      }
  
      /**
       * @return <code>null</code>
       */
      public String formatCookies(Cookie[] cookies) throws IllegalArgumentException {
          return null;
      }
  
      /**
       * @return <code>false</code>
       */
      public boolean match(String host, int port, String path, boolean secure, Cookie 
cookie) {
          return false;
      }
  
      /**
       * Returns an empty [EMAIL PROTECTED] Cookie cookie} array.  All parameters are 
ignored.
       */
      public Cookie[] match(String host, int port, String path, boolean secure, 
Cookie[] cookies) {
          return new Cookie[0];
      }
  
      /**
       * Returns an empty [EMAIL PROTECTED] Cookie cookie} array.  All parameters are 
ignored.
       */
      public Cookie[] parse(String host, int port, String path, boolean secure, Header 
header)
          throws MalformedCookieException, IllegalArgumentException {
          return new Cookie[0];
      }
  
      /**
       * Does nothing.
       */
      public void parseAttribute(NameValuePair attribute, Cookie cookie)
          throws MalformedCookieException, IllegalArgumentException {
      }
  
      /**
       * Does nothing.
       */
      public void validate(String host, int port, String path, boolean secure, Cookie 
cookie)
          throws MalformedCookieException, IllegalArgumentException {
      }
  
  }
  
  
  
  1.26      +35 -13    
jakarta-commons/httpclient/src/test/org/apache/commons/httpclient/TestCookie.java
  
  Index: TestCookie.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-commons/httpclient/src/test/org/apache/commons/httpclient/TestCookie.java,v
  retrieving revision 1.25
  retrieving revision 1.26
  diff -u -r1.25 -r1.26
  --- TestCookie.java   20 Oct 2003 22:26:28 -0000      1.25
  +++ TestCookie.java   2 Nov 2003 18:18:30 -0000       1.26
  @@ -62,16 +62,20 @@
   
   package org.apache.commons.httpclient;
   
  -import junit.framework.Test;
  -import junit.framework.TestCase;
  -import junit.framework.TestSuite;
  -
   import java.util.Date;
  -import java.util.Vector;
  +import java.util.Iterator;
   import java.util.SortedSet;
   import java.util.TreeSet;
  -import java.util.Iterator;
  -import org.apache.commons.httpclient.cookie.*;
  +import java.util.Vector;
  +
  +import junit.framework.Test;
  +import junit.framework.TestSuite;
  +
  +import org.apache.commons.httpclient.cookie.CookiePolicy;
  +import org.apache.commons.httpclient.cookie.CookieSpec;
  +import org.apache.commons.httpclient.cookie.CookieSpecBase;
  +import org.apache.commons.httpclient.cookie.MalformedCookieException;
  +import org.apache.commons.httpclient.methods.GetMethod;
   
   
   /**
  @@ -85,7 +89,7 @@
    * @author <a href="mailto:[EMAIL PROTECTED]">Oleg Kalnichevski</a>
    * @version $Revision$
    */
  -public class TestCookie extends TestCase {
  +public class TestCookie extends TestNoHostBase {
   
   
       // -------------------------------------------------------------- Constants
  @@ -760,11 +764,29 @@
       /**
        * Tests default constructor.
        */
  -    public void testDefaultConsttuctor() {
  +    public void testDefaultConstuctor() {
           Cookie dummy = new Cookie();
           assertEquals( "noname=", dummy.toExternalForm() );
       }
   
  +    public void testIgnoreCookies() throws Exception {
  +        String headers = 
  +            "HTTP/1.1 401 OK\r\n" +
  +            "Connection: close\r\n" +
  +            "Content-Length: 0\r\n" +
  +            "Set-Cookie: custno = 12345; comment=test; version=1," +
  +            " name=John; version=1; max-age=600; secure; domain=.apache.org";
  +        
  +        conn.addResponse(headers);
  +        
  +        GetMethod get = new GetMethod("/");
  +        get.getParams().setCookiePolicy(CookiePolicy.IGNORE_COOKIES);
  +        client.executeMethod(get);
  +        
  +        assertEquals("Cookie parsing should have been disabled", 
  +                0, client.getState().getCookies().length);
  +    }
  +    
       /**
        * Tests whether domain attribute check is case-insensitive.
        */
  
  
  
  1.16      +4 -0      jakarta-commons/httpclient/release_notes.txt
  
  Index: release_notes.txt
  ===================================================================
  RCS file: /home/cvs/jakarta-commons/httpclient/release_notes.txt,v
  retrieving revision 1.15
  retrieving revision 1.16
  diff -u -r1.15 -r1.16
  --- release_notes.txt 7 Oct 2003 20:46:03 -0000       1.15
  +++ release_notes.txt 2 Nov 2003 18:18:30 -0000       1.16
  @@ -1,5 +1,9 @@
   Changes on the CVS trunk:
   
  + * 24012 - Added IgnoreCookiesSpec.
  + 
  + * 24018 - Cookie and Authorization headers can now be set manually.
  + 
    * 10790 - Implemented granular non-standards configuration and tracking.
   
    * 15435 - Implemented new preference architecture.
  
  
  

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

Reply via email to