Index: java/org/apache/commons/httpclient/cookie/CookiePolicy.java =================================================================== RCS file: /home/cvspublic/jakarta-commons/httpclient/src/java/org/apache/commons/httpclient/cookie/CookiePolicy.java,v retrieving revision 1.9 diff -u -r1.9 CookiePolicy.java --- java/org/apache/commons/httpclient/cookie/CookiePolicy.java 20 Oct 2003 22:17:12 -0000 1.9 +++ java/org/apache/commons/httpclient/cookie/CookiePolicy.java 29 Oct 2003 04:59:26 -0000 @@ -109,6 +109,11 @@ public static final String RFC_2109 = "rfc2109"; /** + * The policy that does not parse cookies. + */ + public static final String DISABLE_COOKIE_PARSING = "disableCookieParsing"; + + /** * 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(DISABLE_COOKIE_PARSING, new DisableCookieParsingSpec()); } /** Index: test/org/apache/commons/httpclient/TestCookie.java =================================================================== RCS file: /home/cvspublic/jakarta-commons/httpclient/src/test/org/apache/commons/httpclient/TestCookie.java,v retrieving revision 1.25 diff -u -r1.25 TestCookie.java --- test/org/apache/commons/httpclient/TestCookie.java 20 Oct 2003 22:26:28 -0000 1.25 +++ test/org/apache/commons/httpclient/TestCookie.java 29 Oct 2003 04:59:29 -0000 @@ -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 Oleg Kalnichevski * @version $Revision: 1.25 $ */ -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 testDisableParsing() 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.DISABLE_COOKIE_PARSING); + client.executeMethod(get); + + assertEquals("Cookie parsing should have been disabled", + 0, client.getState().getCookies().length); + } + /** * Tests whether domain attribute check is case-insensitive. */ Index: src/java/org/apache/commons/httpclient/cookie/DisableCookieParsingSpec.java =================================================================== RCS file: src/java/org/apache/commons/httpclient/cookie/DisableCookieParsingSpec.java diff -N src/java/org/apache/commons/httpclient/cookie/DisableCookieParsingSpec.java --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ src/java/org/apache/commons/httpclient/cookie/DisableCookieParsingSpec.java 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,91 @@ +/* + * $Header: $ + * $Revision: $ + * $Date: $ + * + * ==================================================================== + * + * 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 apache@apache.org. + * + * 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 + * . + * + * [Additional notices, if required by prior licensing conditions] + * + */ + +package org.apache.commons.httpclient.cookie; + +import org.apache.commons.httpclient.Cookie; + +/** + * A cookie spec does not parse cookies. All parse methods are no-ops that return an empty + * Cookie array. All other methods delegate to the CookieSpecBase. + * + * @since 2.1 + */ +public class DisableCookieParsingSpec extends CookieSpecBase { + + /** + * + */ + public DisableCookieParsingSpec() { + super(); + } + + /** + * Returns an empty 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]; + } + +}