hc-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Dmitry Potapov <potapo...@gmail.com>
Subject httpasyncclient in master is incompatible with httpclient in master
Date Fri, 05 Sep 2014 15:51:05 GMT
Hello everyone,

I've tried to update httpclient and httpasyncclient to latest revisions and got the following
org.apache.http.HttpException: Unsupported cookie policy: default
        at org.apache.http.client.protocol.RequestAddCookies.process(RequestAddCookies.java:151)
        at org.apache.http.protocol.ImmutableHttpProcessor.process(ImmutableHttpProcessor.java:132)
        at org.apache.http.impl.nio.client.MainClientExec.prepareRequest(MainClientExec.java:553)
        at org.apache.http.impl.nio.client.MainClientExec.prepare(MainClientExec.java:156)
        at org.apache.http.impl.nio.client.DefaultClientExchangeHandlerImpl.start(DefaultClientExchangeHandlerImpl.java:125)
        at org.apache.http.impl.nio.client.InternalHttpAsyncClient.execute(InternalHttpAsyncClient.java:128)

This is caused by r1620939 (Replaced BEST_MATCH with DEFAULT policy) at httpclient:
HttpClientBuilder registers DEFAULT policy in CookieSpecProvider while HttpAsyncClientBuilder
doesn't know about DEFAULT policy, which leads to exception in RequestAddCookies.
I understand perfectly well that trunk builds doesn't have to provide sane behaviour, but
it seems that next stable HttpClient release will be incompatible with HttpAsyncClient 4.0,
which seems pretty strange.

Probably RequestAddCookies.process(...) should just return from function instead of throwing
exception on unknown cookie policy? i.e. apply patch like this:

--- httpclient/src/main/java/org/apache/http/client/protocol/RequestAddCookies.java     (revision
+++ httpclient/src/main/java/org/apache/http/client/protocol/RequestAddCookies.java     (working
@@ -148,7 +148,11 @@
         // Get an instance of the selected cookie policy
         final CookieSpecProvider provider = registry.lookup(policy);
         if (provider == null) {
-            throw new HttpException("Unsupported cookie policy: " + policy);
+            if (this.log.isDebugEnabled()) {
+                this.log.debug("Unsupported cookie policy: " + policy);
+            }
+            return;
         final CookieSpec cookieSpec = provider.create(clientContext);
         // Get all cookies available in the HTTP state

Thanks in advance,
Dmitry Potapov

To unsubscribe, e-mail: dev-unsubscribe@hc.apache.org
For additional commands, e-mail: dev-help@hc.apache.org

View raw message