hc-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ol...@apache.org
Subject svn commit: r1620940 - in /httpcomponents/httpclient/trunk/httpclient/src: main/java-deprecated/org/apache/http/impl/cookie/ main/java/org/apache/http/client/config/ main/java/org/apache/http/impl/client/ main/java/org/apache/http/impl/cookie/ test/jav...
Date Wed, 27 Aug 2014 17:07:53 GMT
Author: olegk
Date: Wed Aug 27 17:07:53 2014
New Revision: 1620940

URL: http://svn.apache.org/r1620940
Log:
Deprecated browser compat policy in favor of the default (best match) policy

Added:
    httpcomponents/httpclient/trunk/httpclient/src/main/java-deprecated/org/apache/http/impl/cookie/BrowserCompatSpec.java
  (contents, props changed)
      - copied, changed from r1620939, httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/cookie/BrowserCompatSpec.java
    httpcomponents/httpclient/trunk/httpclient/src/main/java-deprecated/org/apache/http/impl/cookie/BrowserCompatSpecFactory.java
  (contents, props changed)
      - copied, changed from r1620939, httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/cookie/BrowserCompatSpecFactory.java
    httpcomponents/httpclient/trunk/httpclient/src/main/java-deprecated/org/apache/http/impl/cookie/BrowserCompatVersionAttributeHandler.java
  (contents, props changed)
      - copied, changed from r1620939, httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/cookie/BrowserCompatVersionAttributeHandler.java
Removed:
    httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/cookie/BrowserCompatSpec.java
    httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/cookie/BrowserCompatSpecFactory.java
    httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/cookie/BrowserCompatVersionAttributeHandler.java
    httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/impl/cookie/TestBrowserCompatSpec.java
Modified:
    httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/client/config/CookieSpecs.java
    httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/client/HttpClientBuilder.java
    httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/cookie/DefaultCookieSpec.java
    httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/client/protocol/TestRequestAddCookies.java

Copied: httpcomponents/httpclient/trunk/httpclient/src/main/java-deprecated/org/apache/http/impl/cookie/BrowserCompatSpec.java
(from r1620939, httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/cookie/BrowserCompatSpec.java)
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient/src/main/java-deprecated/org/apache/http/impl/cookie/BrowserCompatSpec.java?p2=httpcomponents/httpclient/trunk/httpclient/src/main/java-deprecated/org/apache/http/impl/cookie/BrowserCompatSpec.java&p1=httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/cookie/BrowserCompatSpec.java&r1=1620939&r2=1620940&rev=1620940&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/cookie/BrowserCompatSpec.java
(original)
+++ httpcomponents/httpclient/trunk/httpclient/src/main/java-deprecated/org/apache/http/impl/cookie/BrowserCompatSpec.java
Wed Aug 27 17:07:53 2014
@@ -56,6 +56,7 @@ import org.apache.http.util.CharArrayBuf
  * common web browser applications such as Microsoft Internet Explorer
  * and Mozilla FireFox.
  *
+ * @deprecated (4.4) use {@link org.apache.http.impl.cookie.DefaultCookieSpec}.
  *
  * @since 4.0
  */

Propchange: httpcomponents/httpclient/trunk/httpclient/src/main/java-deprecated/org/apache/http/impl/cookie/BrowserCompatSpec.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: httpcomponents/httpclient/trunk/httpclient/src/main/java-deprecated/org/apache/http/impl/cookie/BrowserCompatSpec.java
------------------------------------------------------------------------------
    svn:keywords = Date Revision

Propchange: httpcomponents/httpclient/trunk/httpclient/src/main/java-deprecated/org/apache/http/impl/cookie/BrowserCompatSpec.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Copied: httpcomponents/httpclient/trunk/httpclient/src/main/java-deprecated/org/apache/http/impl/cookie/BrowserCompatSpecFactory.java
(from r1620939, httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/cookie/BrowserCompatSpecFactory.java)
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient/src/main/java-deprecated/org/apache/http/impl/cookie/BrowserCompatSpecFactory.java?p2=httpcomponents/httpclient/trunk/httpclient/src/main/java-deprecated/org/apache/http/impl/cookie/BrowserCompatSpecFactory.java&p1=httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/cookie/BrowserCompatSpecFactory.java&r1=1620939&r2=1620940&rev=1620940&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/cookie/BrowserCompatSpecFactory.java
(original)
+++ httpcomponents/httpclient/trunk/httpclient/src/main/java-deprecated/org/apache/http/impl/cookie/BrowserCompatSpecFactory.java
Wed Aug 27 17:07:53 2014
@@ -42,10 +42,12 @@ import org.apache.http.protocol.HttpCont
  * {@link org.apache.http.impl.cookie.BrowserCompatSpec}. The instance returned by this factory
  * can be shared by multiple threads.
  *
+ * @deprecated (4.4) use {@link org.apache.http.impl.cookie.DefaultCookieSpecProvider}.
+ *
  * @since 4.0
  */
 @Immutable
-@SuppressWarnings("deprecation")
+@Deprecated
 public class BrowserCompatSpecFactory implements CookieSpecFactory, CookieSpecProvider {
 
     public enum SecurityLevel {

Propchange: httpcomponents/httpclient/trunk/httpclient/src/main/java-deprecated/org/apache/http/impl/cookie/BrowserCompatSpecFactory.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: httpcomponents/httpclient/trunk/httpclient/src/main/java-deprecated/org/apache/http/impl/cookie/BrowserCompatSpecFactory.java
------------------------------------------------------------------------------
    svn:keywords = Date Revision

Propchange: httpcomponents/httpclient/trunk/httpclient/src/main/java-deprecated/org/apache/http/impl/cookie/BrowserCompatSpecFactory.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Copied: httpcomponents/httpclient/trunk/httpclient/src/main/java-deprecated/org/apache/http/impl/cookie/BrowserCompatVersionAttributeHandler.java
(from r1620939, httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/cookie/BrowserCompatVersionAttributeHandler.java)
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient/src/main/java-deprecated/org/apache/http/impl/cookie/BrowserCompatVersionAttributeHandler.java?p2=httpcomponents/httpclient/trunk/httpclient/src/main/java-deprecated/org/apache/http/impl/cookie/BrowserCompatVersionAttributeHandler.java&p1=httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/cookie/BrowserCompatVersionAttributeHandler.java&r1=1620939&r2=1620940&rev=1620940&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/cookie/BrowserCompatVersionAttributeHandler.java
(original)
+++ httpcomponents/httpclient/trunk/httpclient/src/main/java-deprecated/org/apache/http/impl/cookie/BrowserCompatVersionAttributeHandler.java
Wed Aug 27 17:07:53 2014
@@ -37,6 +37,8 @@ import org.apache.http.util.Args;
 /**
  * {@code "Version"} cookie attribute handler for BrowserCompat cookie spec.
  *
+ *  @deprecated (4.4) no longer used.
+ *
  * @since 4.3
  */
 @Immutable

Propchange: httpcomponents/httpclient/trunk/httpclient/src/main/java-deprecated/org/apache/http/impl/cookie/BrowserCompatVersionAttributeHandler.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: httpcomponents/httpclient/trunk/httpclient/src/main/java-deprecated/org/apache/http/impl/cookie/BrowserCompatVersionAttributeHandler.java
------------------------------------------------------------------------------
    svn:keywords = Date Revision

Propchange: httpcomponents/httpclient/trunk/httpclient/src/main/java-deprecated/org/apache/http/impl/cookie/BrowserCompatVersionAttributeHandler.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Modified: httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/client/config/CookieSpecs.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/client/config/CookieSpecs.java?rev=1620940&r1=1620939&r2=1620940&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/client/config/CookieSpecs.java
(original)
+++ httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/client/config/CookieSpecs.java
Wed Aug 27 17:07:53 2014
@@ -40,7 +40,10 @@ public final class CookieSpecs {
     /**
      * The policy that provides high degree of compatibility
      * with common cookie management of popular HTTP agents.
+     *
+     * @deprecated (4.4) use {link #DEFAULT}.
      */
+    @Deprecated
     public static final String BROWSER_COMPATIBILITY = "compatibility";
 
     /**
@@ -55,13 +58,16 @@ public final class CookieSpecs {
 
     /**
      * The default 'best match' policy.
-     * @deprecated (4.4) use {@link #DEFAULT}.
+     *
+     * @deprecated (4.4) use {link #DEFAULT}.
      */
     @Deprecated
     public static final String BEST_MATCH = "best-match";
 
     /**
-     * The default policy.
+     * The default policy. This policy provides a higher degree of compatibility
+     * with common cookie management of popular HTTP agents for non-standard
+     * (Netscape style) cookies.
      */
     public static final String DEFAULT = "default";
 

Modified: httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/client/HttpClientBuilder.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/client/HttpClientBuilder.java?rev=1620940&r1=1620939&r2=1620940&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/client/HttpClientBuilder.java
(original)
+++ httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/client/HttpClientBuilder.java
Wed Aug 27 17:07:53 2014
@@ -97,11 +97,9 @@ import org.apache.http.impl.conn.Default
 import org.apache.http.impl.conn.DefaultSchemePortResolver;
 import org.apache.http.impl.conn.PoolingHttpClientConnectionManager;
 import org.apache.http.impl.conn.SystemDefaultRoutePlanner;
-import org.apache.http.impl.cookie.BrowserCompatSpecFactory;
 import org.apache.http.impl.cookie.DefaultCookieSpecProvider;
 import org.apache.http.impl.cookie.IgnoreSpecFactory;
 import org.apache.http.impl.cookie.NetscapeDraftSpecFactory;
-import org.apache.http.impl.cookie.RFC2109SpecFactory;
 import org.apache.http.impl.cookie.RFC2965SpecFactory;
 import org.apache.http.impl.execchain.BackoffStrategyExec;
 import org.apache.http.impl.execchain.ClientExecChain;
@@ -1051,11 +1049,8 @@ public class HttpClientBuilder {
             cookieSpecRegistryCopy = RegistryBuilder.<CookieSpecProvider>create()
                 .register(CookieSpecs.DEFAULT, new DefaultCookieSpecProvider())
                 .register(CookieSpecs.STANDARD, new RFC2965SpecFactory())
-                .register(CookieSpecs.BROWSER_COMPATIBILITY, new BrowserCompatSpecFactory())
                 .register(CookieSpecs.NETSCAPE, new NetscapeDraftSpecFactory())
                 .register(CookieSpecs.IGNORE_COOKIES, new IgnoreSpecFactory())
-                .register("rfc2109", new RFC2109SpecFactory())
-                .register("rfc2965", new RFC2965SpecFactory())
                 .build();
         }
 

Modified: httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/cookie/DefaultCookieSpec.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/cookie/DefaultCookieSpec.java?rev=1620940&r1=1620939&r2=1620940&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/cookie/DefaultCookieSpec.java
(original)
+++ httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/cookie/DefaultCookieSpec.java
Wed Aug 27 17:07:53 2014
@@ -52,11 +52,19 @@ import org.apache.http.util.CharArrayBuf
 @ThreadSafe
 public class DefaultCookieSpec implements CookieSpec {
 
+    public enum CompatibilityLevel {
+        DEFAULT,
+        IE_MEDIUM_SECURITY
+    }
+
     private final RFC2965Spec strict;
     private final RFC2109Spec obsoleteStrict;
     private final NetscapeDraftSpec netscapeDraft;
 
-    public DefaultCookieSpec(final String[] datepatterns, final boolean oneHeader) {
+    public DefaultCookieSpec(
+            final String[] datepatterns,
+            final boolean oneHeader,
+            final CompatibilityLevel compatibilityLevel) {
         super();
         this.strict = new RFC2965Spec(oneHeader,
                 new RFC2965VersionAttributeHandler(),
@@ -77,13 +85,25 @@ public class DefaultCookieSpec implement
                 new BasicCommentHandler());
         this.netscapeDraft = new NetscapeDraftSpec(
                 new BasicDomainHandler(),
-                new BasicPathHandler(),
+                compatibilityLevel == CompatibilityLevel.IE_MEDIUM_SECURITY ?
+                        new BasicPathHandler() {
+                            @Override
+                            public void validate(final Cookie cookie, final CookieOrigin
origin) throws MalformedCookieException {
+                                // No validation
+                            }
+                        } : new BasicPathHandler(),
                 new BasicSecureHandler(),
                 new BasicCommentHandler(),
                 new BasicExpiresHandler(
                         datepatterns != null ? datepatterns.clone() : new String[]{NetscapeDraftSpec.EXPIRES_PATTERN}));
     }
 
+    public DefaultCookieSpec(
+            final String[] datepatterns,
+            final boolean oneHeader) {
+        this(datepatterns, oneHeader, null);
+    }
+
     public DefaultCookieSpec() {
         this(null, false);
     }

Modified: httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/client/protocol/TestRequestAddCookies.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/client/protocol/TestRequestAddCookies.java?rev=1620940&r1=1620939&r2=1620940&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/client/protocol/TestRequestAddCookies.java
(original)
+++ httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/client/protocol/TestRequestAddCookies.java
Wed Aug 27 17:07:53 2014
@@ -47,10 +47,9 @@ import org.apache.http.cookie.SM;
 import org.apache.http.impl.client.BasicCookieStore;
 import org.apache.http.impl.cookie.BasicClientCookie;
 import org.apache.http.impl.cookie.BasicClientCookie2;
-import org.apache.http.impl.cookie.BrowserCompatSpec;
-import org.apache.http.impl.cookie.BrowserCompatSpecFactory;
 import org.apache.http.impl.cookie.DefaultCookieSpecProvider;
 import org.apache.http.impl.cookie.IgnoreSpecFactory;
+import org.apache.http.impl.cookie.NetscapeDraftSpec;
 import org.apache.http.impl.cookie.NetscapeDraftSpecFactory;
 import org.apache.http.impl.cookie.RFC2965SpecFactory;
 import org.apache.http.message.BasicHttpRequest;
@@ -83,7 +82,6 @@ public class TestRequestAddCookies {
         this.cookieSpecRegistry = RegistryBuilder.<CookieSpecProvider>create()
             .register(CookieSpecs.DEFAULT, new DefaultCookieSpecProvider())
             .register(CookieSpecs.STANDARD, new RFC2965SpecFactory())
-            .register(CookieSpecs.BROWSER_COMPATIBILITY, new BrowserCompatSpecFactory())
             .register(CookieSpecs.NETSCAPE, new NetscapeDraftSpecFactory())
             .register(CookieSpecs.IGNORE_COOKIES, new IgnoreSpecFactory())
             .build();
@@ -252,7 +250,7 @@ public class TestRequestAddCookies {
     public void testAddCookiesUsingExplicitCookieSpec() throws Exception {
         final HttpRequest request = new BasicHttpRequest("GET", "/");
         final RequestConfig config = RequestConfig.custom()
-            .setCookieSpec(CookieSpecs.BROWSER_COMPATIBILITY).build();
+            .setCookieSpec(CookieSpecs.NETSCAPE).build();
         final HttpRoute route = new HttpRoute(this.target, null, false);
 
         final HttpClientContext context = HttpClientContext.create();
@@ -266,7 +264,7 @@ public class TestRequestAddCookies {
         interceptor.process(request, context);
 
         final CookieSpec cookieSpec = context.getCookieSpec();
-        Assert.assertTrue(cookieSpec instanceof BrowserCompatSpec);
+        Assert.assertTrue(cookieSpec instanceof NetscapeDraftSpec);
 
         final Header[] headers1 = request.getHeaders(SM.COOKIE);
         Assert.assertNotNull(headers1);



Mime
View raw message