hc-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ol...@apache.org
Subject svn commit: r1432030 - in /httpcomponents/httpclient/trunk/httpclient/src: examples/org/apache/http/examples/client/ main/java/org/apache/http/impl/client/ main/java/org/apache/http/impl/conn/ test/java/org/apache/http/impl/client/integration/
Date Fri, 11 Jan 2013 13:11:48 GMT
Author: olegk
Date: Fri Jan 11 13:11:48 2013
New Revision: 1432030

URL: http://svn.apache.org/viewvc?rev=1432030&view=rev
Log:
Minor API tweaks; expanded ClientConfiguration example

Modified:
    httpcomponents/httpclient/trunk/httpclient/src/examples/org/apache/http/examples/client/ClientAuthentication.java
    httpcomponents/httpclient/trunk/httpclient/src/examples/org/apache/http/examples/client/ClientConfiguration.java
    httpcomponents/httpclient/trunk/httpclient/src/examples/org/apache/http/examples/client/ClientFormLogin.java
    httpcomponents/httpclient/trunk/httpclient/src/examples/org/apache/http/examples/client/ClientInteractiveAuthentication.java
    httpcomponents/httpclient/trunk/httpclient/src/examples/org/apache/http/examples/client/ClientPreemptiveBasicAuthentication.java
    httpcomponents/httpclient/trunk/httpclient/src/examples/org/apache/http/examples/client/ClientPreemptiveDigestAuthentication.java
    httpcomponents/httpclient/trunk/httpclient/src/examples/org/apache/http/examples/client/ClientProxyAuthentication.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/conn/DefaultClientConnectionFactory.java
    httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/conn/DefaultHttpResponseParser.java
    httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/conn/PoolingHttpClientConnectionManager.java
    httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/impl/client/integration/TestClientAuthentication.java
    httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/impl/client/integration/TestClientAuthenticationFallBack.java
    httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/impl/client/integration/TestClientReauthentication.java
    httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/impl/client/integration/TestSPNegoScheme.java

Modified: httpcomponents/httpclient/trunk/httpclient/src/examples/org/apache/http/examples/client/ClientAuthentication.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient/src/examples/org/apache/http/examples/client/ClientAuthentication.java?rev=1432030&r1=1432029&r2=1432030&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient/src/examples/org/apache/http/examples/client/ClientAuthentication.java
(original)
+++ httpcomponents/httpclient/trunk/httpclient/src/examples/org/apache/http/examples/client/ClientAuthentication.java
Fri Jan 11 13:11:48 2013
@@ -49,7 +49,7 @@ public class ClientAuthentication {
                 new AuthScope("localhost", 443),
                 new UsernamePasswordCredentials("username", "password"));
         CloseableHttpClient httpclient = HttpClients.custom()
-                .setCredentialsProvider(credsProvider).build();
+                .setDefaultCredentialsProvider(credsProvider).build();
         try {
             HttpGet httpget = new HttpGet("https://localhost/protected");
 

Modified: httpcomponents/httpclient/trunk/httpclient/src/examples/org/apache/http/examples/client/ClientConfiguration.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient/src/examples/org/apache/http/examples/client/ClientConfiguration.java?rev=1432030&r1=1432029&r2=1432030&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient/src/examples/org/apache/http/examples/client/ClientConfiguration.java
(original)
+++ httpcomponents/httpclient/trunk/httpclient/src/examples/org/apache/http/examples/client/ClientConfiguration.java
Fri Jan 11 13:11:48 2013
@@ -27,17 +27,20 @@
 
 package org.apache.http.examples.client;
 
+import java.net.InetAddress;
+import java.net.UnknownHostException;
 import java.nio.charset.CodingErrorAction;
 import java.util.Arrays;
 
 import javax.net.ssl.SSLContext;
 
 import org.apache.http.Consts;
+import org.apache.http.Header;
 import org.apache.http.HttpEntity;
 import org.apache.http.HttpHost;
 import org.apache.http.HttpRequest;
 import org.apache.http.HttpResponse;
-import org.apache.http.HttpResponseFactory;
+import org.apache.http.ParseException;
 import org.apache.http.client.CookieStore;
 import org.apache.http.client.CredentialsProvider;
 import org.apache.http.client.config.AuthSchemes;
@@ -66,12 +69,19 @@ import org.apache.http.impl.client.Basic
 import org.apache.http.impl.client.CloseableHttpClient;
 import org.apache.http.impl.client.HttpClients;
 import org.apache.http.impl.conn.DefaultClientConnectionFactory;
+import org.apache.http.impl.conn.DefaultHttpResponseParser;
 import org.apache.http.impl.conn.DefaultHttpResponseParserFactory;
 import org.apache.http.impl.conn.PoolingHttpClientConnectionManager;
 import org.apache.http.impl.conn.SystemDefaultDnsResolver;
 import org.apache.http.impl.io.DefaultHttpRequestWriterFactory;
+import org.apache.http.io.HttpMessageParser;
 import org.apache.http.io.HttpMessageParserFactory;
 import org.apache.http.io.HttpMessageWriterFactory;
+import org.apache.http.io.SessionInputBuffer;
+import org.apache.http.message.BasicHeader;
+import org.apache.http.message.BasicLineParser;
+import org.apache.http.message.LineParser;
+import org.apache.http.util.CharArrayBuffer;
 
 /**
  * This example demonstrates how to customize and configure the most common aspects
@@ -81,14 +91,38 @@ public class ClientConfiguration {
 
     public final static void main(String[] args) throws Exception {
 
-        // Use a custom response factory to customize the way HTTP response
-        // objects are generated.
-        HttpResponseFactory responseFactory = new DefaultHttpResponseFactory();
-
         // Use custom message parser / writer to customize the way HTTP
         // messages are parsed from and written out to the data stream.
-        HttpMessageParserFactory<HttpResponse> responseParserFactory = new DefaultHttpResponseParserFactory(
-                responseFactory);
+        HttpMessageParserFactory<HttpResponse> responseParserFactory = new DefaultHttpResponseParserFactory()
{
+
+            @Override
+            public HttpMessageParser<HttpResponse> create(
+                SessionInputBuffer buffer, MessageConstraints constraints) {
+                LineParser lineParser = new BasicLineParser() {
+
+                    @Override
+                    public Header parseHeader(final CharArrayBuffer buffer) {
+                        try {
+                            return super.parseHeader(buffer);
+                        } catch (ParseException ex) {
+                            return new BasicHeader(buffer.toString(), null);
+                        }
+                    }
+
+                };
+                return new DefaultHttpResponseParser(
+                    buffer, lineParser, DefaultHttpResponseFactory.INSTANCE, constraints)
{
+
+                    @Override
+                    protected boolean reject(final CharArrayBuffer line, int count) {
+                        // try to ignore all garbage preceding a status line infinitely
+                        return false;
+                    }
+
+                };
+            }
+
+        };
         HttpMessageWriterFactory<HttpRequest> requestWriterFactory = new DefaultHttpRequestWriterFactory();
 
         // Use a custom connection factory to customize the process of
@@ -118,7 +152,18 @@ public class ClientConfiguration {
             .build();
 
         // Use custom DNS resolver to override the system DNS resolution.
-        DnsResolver dnsResolver = new SystemDefaultDnsResolver();
+        DnsResolver dnsResolver = new SystemDefaultDnsResolver() {
+
+            @Override
+            public InetAddress[] resolve(final String host) throws UnknownHostException {
+                if (host.equalsIgnoreCase("myhost")) {
+                    return new InetAddress[] { InetAddress.getByAddress(new byte[] {127,
0, 0, 1}) };
+                } else {
+                    return super.resolve(host);
+                }
+            }
+
+        };
 
         // Create a connection manager with custom configuration.
         PoolingHttpClientConnectionManager connManager = new PoolingHttpClientConnectionManager(
@@ -172,8 +217,8 @@ public class ClientConfiguration {
         // Create an HttpClient with the given custom dependencies and configuration.
         CloseableHttpClient httpclient = HttpClients.custom()
             .setConnectionManager(connManager)
-            .setCookieStore(cookieStore)
-            .setCredentialsProvider(credentialsProvider)
+            .setDefaultCookieStore(cookieStore)
+            .setDefaultCredentialsProvider(credentialsProvider)
             .setProxy(new HttpHost("myproxy", 8080))
             .setDefaultRequestConfig(defaultRequestConfig)
             .build();

Modified: httpcomponents/httpclient/trunk/httpclient/src/examples/org/apache/http/examples/client/ClientFormLogin.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient/src/examples/org/apache/http/examples/client/ClientFormLogin.java?rev=1432030&r1=1432029&r2=1432030&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient/src/examples/org/apache/http/examples/client/ClientFormLogin.java
(original)
+++ httpcomponents/httpclient/trunk/httpclient/src/examples/org/apache/http/examples/client/ClientFormLogin.java
Fri Jan 11 13:11:48 2013
@@ -51,7 +51,7 @@ public class ClientFormLogin {
 
     public static void main(String[] args) throws Exception {
         BasicCookieStore cookieStore = new BasicCookieStore();
-        CloseableHttpClient httpclient = HttpClients.custom().setCookieStore(cookieStore).build();
+        CloseableHttpClient httpclient = HttpClients.custom().setDefaultCookieStore(cookieStore).build();
         try {
             HttpGet httpget = new HttpGet("https://portal.sun.com/portal/dt");
 

Modified: httpcomponents/httpclient/trunk/httpclient/src/examples/org/apache/http/examples/client/ClientInteractiveAuthentication.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient/src/examples/org/apache/http/examples/client/ClientInteractiveAuthentication.java?rev=1432030&r1=1432029&r2=1432030&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient/src/examples/org/apache/http/examples/client/ClientInteractiveAuthentication.java
(original)
+++ httpcomponents/httpclient/trunk/httpclient/src/examples/org/apache/http/examples/client/ClientInteractiveAuthentication.java
Fri Jan 11 13:11:48 2013
@@ -55,7 +55,7 @@ public class ClientInteractiveAuthentica
     public static void main(String[] args) throws Exception {
         BasicCredentialsProvider credsProvider = new BasicCredentialsProvider();
         CloseableHttpClient httpclient = HttpClients.custom()
-                .setCredentialsProvider(credsProvider).build();
+                .setDefaultCredentialsProvider(credsProvider).build();
         try {
             // Create local execution context
             HttpClientContext localContext = HttpClientContext.create();

Modified: httpcomponents/httpclient/trunk/httpclient/src/examples/org/apache/http/examples/client/ClientPreemptiveBasicAuthentication.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient/src/examples/org/apache/http/examples/client/ClientPreemptiveBasicAuthentication.java?rev=1432030&r1=1432029&r2=1432030&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient/src/examples/org/apache/http/examples/client/ClientPreemptiveBasicAuthentication.java
(original)
+++ httpcomponents/httpclient/trunk/httpclient/src/examples/org/apache/http/examples/client/ClientPreemptiveBasicAuthentication.java
Fri Jan 11 13:11:48 2013
@@ -59,7 +59,7 @@ public class ClientPreemptiveBasicAuthen
                 new AuthScope(targetHost.getHostName(), targetHost.getPort()),
                 new UsernamePasswordCredentials("username", "password"));
         CloseableHttpClient httpclient = HttpClients.custom()
-                .setCredentialsProvider(credsProvider).build();
+                .setDefaultCredentialsProvider(credsProvider).build();
         try {
 
             // Create AuthCache instance

Modified: httpcomponents/httpclient/trunk/httpclient/src/examples/org/apache/http/examples/client/ClientPreemptiveDigestAuthentication.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient/src/examples/org/apache/http/examples/client/ClientPreemptiveDigestAuthentication.java?rev=1432030&r1=1432029&r2=1432030&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient/src/examples/org/apache/http/examples/client/ClientPreemptiveDigestAuthentication.java
(original)
+++ httpcomponents/httpclient/trunk/httpclient/src/examples/org/apache/http/examples/client/ClientPreemptiveDigestAuthentication.java
Fri Jan 11 13:11:48 2013
@@ -59,7 +59,7 @@ public class ClientPreemptiveDigestAuthe
                 new AuthScope(targetHost.getHostName(), targetHost.getPort()),
                 new UsernamePasswordCredentials("username", "password"));
         CloseableHttpClient httpclient = HttpClients.custom()
-                .setCredentialsProvider(credsProvider).build();
+                .setDefaultCredentialsProvider(credsProvider).build();
         try {
 
             // Create AuthCache instance

Modified: httpcomponents/httpclient/trunk/httpclient/src/examples/org/apache/http/examples/client/ClientProxyAuthentication.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient/src/examples/org/apache/http/examples/client/ClientProxyAuthentication.java?rev=1432030&r1=1432029&r2=1432030&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient/src/examples/org/apache/http/examples/client/ClientProxyAuthentication.java
(original)
+++ httpcomponents/httpclient/trunk/httpclient/src/examples/org/apache/http/examples/client/ClientProxyAuthentication.java
Fri Jan 11 13:11:48 2013
@@ -51,7 +51,7 @@ public class ClientProxyAuthentication {
                 new AuthScope("localhost", 8080),
                 new UsernamePasswordCredentials("username", "password"));
         CloseableHttpClient httpclient = HttpClients.custom()
-                .setCredentialsProvider(credsProvider).build();
+                .setDefaultCredentialsProvider(credsProvider).build();
         try {
             HttpHost targetHost = new HttpHost("www.verisign.com", 443, "https");
             HttpHost proxy = new HttpHost("localhost", 8080);

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=1432030&r1=1432029&r2=1432030&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
Fri Jan 11 13:11:48 2013
@@ -31,10 +31,8 @@ import java.io.Closeable;
 import java.net.ProxySelector;
 import java.util.ArrayList;
 import java.util.Collection;
-import java.util.HashMap;
 import java.util.LinkedList;
 import java.util.List;
-import java.util.Map;
 
 import org.apache.http.ConnectionReuseStrategy;
 import org.apache.http.Header;
@@ -165,8 +163,6 @@ public class HttpClientBuilder {
     private ServiceUnavailableRetryStrategy serviceUnavailStrategy;
     private Lookup<AuthSchemeProvider> authSchemeRegistry;
     private Lookup<CookieSpecProvider> cookieSpecRegistry;
-    private Map<String, AuthSchemeProvider> authShemes;
-    private Map<String, CookieSpecProvider> cookieSpecs;
     private CookieStore cookieStore;
     private CredentialsProvider credentialsProvider;
     private String userAgent;
@@ -340,47 +336,29 @@ public class HttpClientBuilder {
         return this;
     }
 
-    public final HttpClientBuilder setCookieStore(final CookieStore cookieStore) {
+    public final HttpClientBuilder setDefaultCookieStore(final CookieStore cookieStore) {
         this.cookieStore = cookieStore;
         return this;
     }
 
-    public final HttpClientBuilder setCredentialsProvider(
+    public final HttpClientBuilder setDefaultCredentialsProvider(
             final CredentialsProvider credentialsProvider) {
         this.credentialsProvider = credentialsProvider;
         return this;
     }
 
-    public final HttpClientBuilder setAuthSchemeRegistry(
+    public final HttpClientBuilder setDefaultAuthSchemeRegistry(
             final Lookup<AuthSchemeProvider> authSchemeRegistry) {
         this.authSchemeRegistry = authSchemeRegistry;
         return this;
     }
 
-    public final HttpClientBuilder setCookieSpecRegistry(
+    public final HttpClientBuilder setDefaultCookieSpecRegistry(
             final Lookup<CookieSpecProvider> cookieSpecRegistry) {
         this.cookieSpecRegistry = cookieSpecRegistry;
         return this;
     }
 
-    public final HttpClientBuilder registerAuthScheme(
-            final String name, final AuthSchemeProvider authSchemeProvider) {
-        if (this.authShemes == null) {
-            this.authShemes = new HashMap<String, AuthSchemeProvider>();
-        }
-        this.authShemes.put(name, authSchemeProvider);
-        return this;
-    }
-
-    public final HttpClientBuilder registerCookiePolicy(
-            final String name, final CookieSpecProvider cookieSpecProvider) {
-        if (this.cookieSpecs == null) {
-            this.cookieSpecs = new HashMap<String, CookieSpecProvider>();
-        }
-        this.cookieSpecs.put(name, cookieSpecProvider);
-        return this;
-    }
-
     public final HttpClientBuilder setUserAgent(final String userAgent) {
         this.userAgent = userAgent;
         return this;
@@ -656,35 +634,24 @@ public class HttpClientBuilder {
 
         Lookup<AuthSchemeProvider> authSchemeRegistry = this.authSchemeRegistry;
         if (authSchemeRegistry == null) {
-            RegistryBuilder<AuthSchemeProvider> b = RegistryBuilder.<AuthSchemeProvider>create();
-            b.register(AuthSchemes.BASIC, new BasicSchemeFactory())
+            authSchemeRegistry = RegistryBuilder.<AuthSchemeProvider>create()
+                .register(AuthSchemes.BASIC, new BasicSchemeFactory())
                 .register(AuthSchemes.DIGEST, new DigestSchemeFactory())
                 .register(AuthSchemes.NTLM, new NTLMSchemeFactory())
                 .register(AuthSchemes.SPNEGO, new SPNegoSchemeFactory())
                 .register(AuthSchemes.KERBEROS, new KerberosSchemeFactory())
                 .build();
-            if (authShemes != null) {
-                for (Map.Entry<String, AuthSchemeProvider> entry: authShemes.entrySet())
{
-                    b.register(entry.getKey(), entry.getValue());
-                }
-            }
-            authSchemeRegistry = b.build();
         }
         Lookup<CookieSpecProvider> cookieSpecRegistry = this.cookieSpecRegistry;
         if (cookieSpecRegistry == null) {
-            RegistryBuilder<CookieSpecProvider> b = RegistryBuilder.<CookieSpecProvider>create();
-            b.register(CookieSpecs.BEST_MATCH, new BestMatchSpecFactory())
+            cookieSpecRegistry = RegistryBuilder.<CookieSpecProvider>create()
+                .register(CookieSpecs.BEST_MATCH, new BestMatchSpecFactory())
                 .register(CookieSpecs.BROWSER_COMPATIBILITY, new BrowserCompatSpecFactory())
                 .register(CookieSpecs.NETSCAPE, new NetscapeDraftSpecFactory())
                 .register(CookieSpecs.RFC_2109, new RFC2109SpecFactory())
                 .register(CookieSpecs.RFC_2965, new RFC2965SpecFactory())
-                .register(CookieSpecs.IGNORE_COOKIES, new IgnoreSpecFactory());
-            if (cookieSpecs != null) {
-                for (Map.Entry<String, CookieSpecProvider> entry: cookieSpecs.entrySet())
{
-                    b.register(entry.getKey(), entry.getValue());
-                }
-            }
-            cookieSpecRegistry = b.build();
+                .register(CookieSpecs.IGNORE_COOKIES, new IgnoreSpecFactory())
+                .build();
         }
 
         CookieStore defaultCookieStore = this.cookieStore;

Modified: httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/conn/DefaultClientConnectionFactory.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/conn/DefaultClientConnectionFactory.java?rev=1432030&r1=1432029&r2=1432030&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/conn/DefaultClientConnectionFactory.java
(original)
+++ httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/conn/DefaultClientConnectionFactory.java
Fri Jan 11 13:11:48 2013
@@ -49,6 +49,8 @@ import org.apache.http.util.Args;
 @Immutable
 public class DefaultClientConnectionFactory implements HttpConnectionFactory<SocketClientConnection>
{
 
+    private static final int DEFAULT_BUFSIZE = 8 * 1024;
+
     public static final DefaultClientConnectionFactory INSTANCE = new DefaultClientConnectionFactory();
 
     private final int bufferSize;
@@ -68,17 +70,22 @@ public class DefaultClientConnectionFact
     }
 
     public DefaultClientConnectionFactory(
+            final HttpMessageWriterFactory<HttpRequest> requestWriterFactory,
             final HttpMessageParserFactory<HttpResponse> responseParserFactory) {
-        this(8 * 1024, null, responseParserFactory);
+        this(DEFAULT_BUFSIZE, requestWriterFactory, responseParserFactory);
     }
 
     public DefaultClientConnectionFactory(
-            int bufferSize) {
+            final HttpMessageParserFactory<HttpResponse> responseParserFactory) {
+        this(null, responseParserFactory);
+    }
+
+    public DefaultClientConnectionFactory(int bufferSize) {
         this(bufferSize, null, null);
     }
 
     public DefaultClientConnectionFactory() {
-        this(8 * 1024, null, null);
+        this(DEFAULT_BUFSIZE, null, null);
     }
 
     public SocketClientConnection create(final ConnectionConfig config) {

Modified: httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/conn/DefaultHttpResponseParser.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/conn/DefaultHttpResponseParser.java?rev=1432030&r1=1432029&r2=1432030&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/conn/DefaultHttpResponseParser.java
(original)
+++ httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/conn/DefaultHttpResponseParser.java
Fri Jan 11 13:11:48 2013
@@ -108,6 +108,20 @@ public class DefaultHttpResponseParser e
      * Creates new instance of DefaultHttpResponseParser.
      *
      * @param buffer the session input buffer.
+     * @param constraints the message constraints. If <code>null</code>
+     *   {@link MessageConstraints#DEFAULT} will be used.
+     *
+     * @since 4.3
+     */
+    public DefaultHttpResponseParser(
+        final SessionInputBuffer buffer, final MessageConstraints constraints) {
+        this(buffer, null, null, constraints);
+    }
+
+    /**
+     * Creates new instance of DefaultHttpResponseParser.
+     *
+     * @param buffer the session input buffer.
      *
      * @since 4.3
      */

Modified: httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/conn/PoolingHttpClientConnectionManager.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/conn/PoolingHttpClientConnectionManager.java?rev=1432030&r1=1432029&r2=1432030&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/conn/PoolingHttpClientConnectionManager.java
(original)
+++ httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/conn/PoolingHttpClientConnectionManager.java
Fri Jan 11 13:11:48 2013
@@ -104,32 +104,36 @@ public class PoolingHttpClientConnection
     }
 
     public PoolingHttpClientConnectionManager(final long timeToLive, final TimeUnit tunit)
{
-        this(getDefaultRegistry(), null, timeToLive, tunit);
+        this(getDefaultRegistry(), null, null ,null, timeToLive, tunit);
     }
 
     public PoolingHttpClientConnectionManager(
             final Registry<ConnectionSocketFactory> socketFactoryRegistry) {
-        this(socketFactoryRegistry, null, -1, TimeUnit.MILLISECONDS);
+        this(socketFactoryRegistry, null, null);
     }
 
     public PoolingHttpClientConnectionManager(
             final Registry<ConnectionSocketFactory> socketFactoryRegistry,
             final DnsResolver dnsResolver) {
-        this(socketFactoryRegistry, null, null, dnsResolver, -1, TimeUnit.MILLISECONDS);
+        this(socketFactoryRegistry, null, dnsResolver);
     }
 
     public PoolingHttpClientConnectionManager(
             final Registry<ConnectionSocketFactory> socketFactoryRegistry,
-            final HttpConnectionFactory<SocketClientConnection> connFactory,
-            final DnsResolver dnsResolver) {
-        this(socketFactoryRegistry, connFactory, null, dnsResolver, -1, TimeUnit.MILLISECONDS);
+            final HttpConnectionFactory<SocketClientConnection> connFactory) {
+        this(socketFactoryRegistry, connFactory, null);
+    }
+
+    public PoolingHttpClientConnectionManager(
+            final HttpConnectionFactory<SocketClientConnection> connFactory) {
+        this(getDefaultRegistry(), connFactory, null);
     }
 
     public PoolingHttpClientConnectionManager(
             final Registry<ConnectionSocketFactory> socketFactoryRegistry,
             final HttpConnectionFactory<SocketClientConnection> connFactory,
-            final long timeToLive, final TimeUnit tunit) {
-        this(socketFactoryRegistry, connFactory, null, null, timeToLive, tunit);
+            final DnsResolver dnsResolver) {
+        this(socketFactoryRegistry, connFactory, null, dnsResolver, -1, TimeUnit.MILLISECONDS);
     }
 
     public PoolingHttpClientConnectionManager(

Modified: httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/impl/client/integration/TestClientAuthentication.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/impl/client/integration/TestClientAuthentication.java?rev=1432030&r1=1432029&r2=1432030&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/impl/client/integration/TestClientAuthentication.java
(original)
+++ httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/impl/client/integration/TestClientAuthentication.java
Fri Jan 11 13:11:48 2013
@@ -166,7 +166,7 @@ public class TestClientAuthentication ex
         this.localServer.register("*", new AuthHandler());
 
         TestCredentialsProvider credsProvider = new TestCredentialsProvider(null);
-        this.httpclient = HttpClients.custom().setCredentialsProvider(credsProvider).build();
+        this.httpclient = HttpClients.custom().setDefaultCredentialsProvider(credsProvider).build();
 
         HttpGet httpget = new HttpGet("/");
 
@@ -187,7 +187,7 @@ public class TestClientAuthentication ex
         TestCredentialsProvider credsProvider = new TestCredentialsProvider(
                 new UsernamePasswordCredentials("test", "all-wrong"));
 
-        this.httpclient = HttpClients.custom().setCredentialsProvider(credsProvider).build();
+        this.httpclient = HttpClients.custom().setDefaultCredentialsProvider(credsProvider).build();
 
         HttpGet httpget = new HttpGet("/");
 
@@ -208,7 +208,7 @@ public class TestClientAuthentication ex
         TestCredentialsProvider credsProvider = new TestCredentialsProvider(
                 new UsernamePasswordCredentials("test", "test"));
 
-        this.httpclient = HttpClients.custom().setCredentialsProvider(credsProvider).build();
+        this.httpclient = HttpClients.custom().setDefaultCredentialsProvider(credsProvider).build();
 
         HttpGet httpget = new HttpGet("/");
 
@@ -239,7 +239,7 @@ public class TestClientAuthentication ex
         TestCredentialsProvider credsProvider = new TestCredentialsProvider(
                 new UsernamePasswordCredentials("test", "test"));
 
-        this.httpclient = HttpClients.custom().setCredentialsProvider(credsProvider).build();
+        this.httpclient = HttpClients.custom().setDefaultCredentialsProvider(credsProvider).build();
 
         RequestConfig config = RequestConfig.custom().setExpectContinueEnabled(true).build();
         HttpPut httpput = new HttpPut("/");
@@ -262,7 +262,7 @@ public class TestClientAuthentication ex
         TestCredentialsProvider credsProvider = new TestCredentialsProvider(
                 new UsernamePasswordCredentials("test", "boom"));
 
-        this.httpclient = HttpClients.custom().setCredentialsProvider(credsProvider).build();
+        this.httpclient = HttpClients.custom().setDefaultCredentialsProvider(credsProvider).build();
 
         RequestConfig config = RequestConfig.custom().setExpectContinueEnabled(true).build();
         HttpPut httpput = new HttpPut("/");
@@ -290,7 +290,7 @@ public class TestClientAuthentication ex
         TestCredentialsProvider credsProvider = new TestCredentialsProvider(
                 new UsernamePasswordCredentials("test", "test"));
 
-        this.httpclient = HttpClients.custom().setCredentialsProvider(credsProvider).build();
+        this.httpclient = HttpClients.custom().setDefaultCredentialsProvider(credsProvider).build();
 
         HttpPost httppost = new HttpPost("/");
         httppost.setEntity(new StringEntity("some important stuff", Consts.ASCII));
@@ -312,7 +312,7 @@ public class TestClientAuthentication ex
         TestCredentialsProvider credsProvider = new TestCredentialsProvider(
                 new UsernamePasswordCredentials("test", "test"));
 
-        this.httpclient = HttpClients.custom().setCredentialsProvider(credsProvider).build();
+        this.httpclient = HttpClients.custom().setDefaultCredentialsProvider(credsProvider).build();
 
         HttpPost httppost = new HttpPost("/");
         httppost.setEntity(new InputStreamEntity(
@@ -366,7 +366,7 @@ public class TestClientAuthentication ex
         TestTargetAuthenticationStrategy authStrategy = new TestTargetAuthenticationStrategy();
 
         this.httpclient = HttpClients.custom()
-            .setCredentialsProvider(credsProvider)
+            .setDefaultCredentialsProvider(credsProvider)
             .setTargetAuthenticationStrategy(authStrategy)
             .build();
 
@@ -462,7 +462,7 @@ public class TestClientAuthentication ex
                 new UsernamePasswordCredentials("test", "test"));
 
         this.httpclient = HttpClients.custom()
-            .setCredentialsProvider(credsProvider)
+            .setDefaultCredentialsProvider(credsProvider)
             .build();
 
         HttpHost targethost = getServerHttp();
@@ -493,7 +493,7 @@ public class TestClientAuthentication ex
                 new UsernamePasswordCredentials("test", "stuff"));
 
         this.httpclient = HttpClients.custom()
-            .setCredentialsProvider(credsProvider)
+            .setDefaultCredentialsProvider(credsProvider)
             .build();
 
         HttpHost targethost = getServerHttp();
@@ -537,7 +537,7 @@ public class TestClientAuthentication ex
         this.localServer.register("*", new ProxyAuthHandler());
 
         TestCredentialsProvider credsProvider = new TestCredentialsProvider(null);
-        this.httpclient = HttpClients.custom().setCredentialsProvider(credsProvider).build();
+        this.httpclient = HttpClients.custom().setDefaultCredentialsProvider(credsProvider).build();
 
         HttpGet httpget = new HttpGet("/");
 

Modified: httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/impl/client/integration/TestClientAuthenticationFallBack.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/impl/client/integration/TestClientAuthenticationFallBack.java?rev=1432030&r1=1432029&r2=1432030&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/impl/client/integration/TestClientAuthenticationFallBack.java
(original)
+++ httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/impl/client/integration/TestClientAuthenticationFallBack.java
Fri Jan 11 13:11:48 2013
@@ -138,7 +138,7 @@ public class TestClientAuthenticationFal
         TestCredentialsProvider credsProvider = new TestCredentialsProvider(
                 new UsernamePasswordCredentials("test", "test"));
 
-        this.httpclient = HttpClients.custom().setCredentialsProvider(credsProvider).build();
+        this.httpclient = HttpClients.custom().setDefaultCredentialsProvider(credsProvider).build();
 
         HttpGet httpget = new HttpGet("/");
 

Modified: httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/impl/client/integration/TestClientReauthentication.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/impl/client/integration/TestClientReauthentication.java?rev=1432030&r1=1432029&r2=1432030&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/impl/client/integration/TestClientReauthentication.java
(original)
+++ httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/impl/client/integration/TestClientReauthentication.java
Fri Jan 11 13:11:48 2013
@@ -39,12 +39,15 @@ import org.apache.http.HttpResponseInter
 import org.apache.http.HttpStatus;
 import org.apache.http.auth.AUTH;
 import org.apache.http.auth.AuthScheme;
+import org.apache.http.auth.AuthSchemeProvider;
 import org.apache.http.auth.AuthScope;
 import org.apache.http.auth.Credentials;
 import org.apache.http.auth.UsernamePasswordCredentials;
 import org.apache.http.client.CredentialsProvider;
 import org.apache.http.client.config.RequestConfig;
 import org.apache.http.client.methods.HttpGet;
+import org.apache.http.config.Registry;
+import org.apache.http.config.RegistryBuilder;
 import org.apache.http.entity.StringEntity;
 import org.apache.http.impl.auth.BasicScheme;
 import org.apache.http.impl.auth.BasicSchemeFactory;
@@ -181,10 +184,13 @@ public class TestClientReauthentication 
         RequestConfig config = RequestConfig.custom()
             .setTargetPreferredAuthSchemes(Arrays.asList("MyBasic"))
             .build();
+        Registry<AuthSchemeProvider> authSchemeRegistry = RegistryBuilder.<AuthSchemeProvider>create()
+            .register("MyBasic", myBasicAuthSchemeFactory)
+            .build();
         this.httpclient = HttpClients.custom()
-            .registerAuthScheme("MyBasic", myBasicAuthSchemeFactory)
+            .setDefaultAuthSchemeRegistry(authSchemeRegistry)
             .setTargetAuthenticationStrategy(myAuthStrategy)
-            .setCredentialsProvider(credsProvider)
+            .setDefaultCredentialsProvider(credsProvider)
             .build();
 
         HttpContext context = new BasicHttpContext();

Modified: httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/impl/client/integration/TestSPNegoScheme.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/impl/client/integration/TestSPNegoScheme.java?rev=1432030&r1=1432029&r2=1432030&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/impl/client/integration/TestSPNegoScheme.java
(original)
+++ httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/impl/client/integration/TestSPNegoScheme.java
Fri Jan 11 13:11:48 2013
@@ -41,6 +41,8 @@ import org.apache.http.auth.Credentials;
 import org.apache.http.client.CredentialsProvider;
 import org.apache.http.client.config.AuthSchemes;
 import org.apache.http.client.methods.HttpGet;
+import org.apache.http.config.Registry;
+import org.apache.http.config.RegistryBuilder;
 import org.apache.http.entity.StringEntity;
 import org.apache.http.impl.auth.SPNegoScheme;
 import org.apache.http.impl.client.BasicCredentialsProvider;
@@ -160,9 +162,12 @@ public class TestSPNegoScheme extends In
         Credentials use_jaas_creds = new UseJaasCredentials();
         credentialsProvider.setCredentials(new AuthScope(null, -1, null), use_jaas_creds);
 
+        Registry<AuthSchemeProvider> authSchemeRegistry = RegistryBuilder.<AuthSchemeProvider>create()
+            .register(AuthSchemes.SPNEGO, nsf)
+            .build();
         this.httpclient = HttpClients.custom()
-            .registerAuthScheme(AuthSchemes.SPNEGO, nsf)
-            .setCredentialsProvider(credentialsProvider)
+            .setDefaultAuthSchemeRegistry(authSchemeRegistry)
+            .setDefaultCredentialsProvider(credentialsProvider)
             .build();
 
         String s = "/path";
@@ -190,9 +195,12 @@ public class TestSPNegoScheme extends In
         Credentials use_jaas_creds = new UseJaasCredentials();
         credentialsProvider.setCredentials(new AuthScope(null, -1, null), use_jaas_creds);
 
+        Registry<AuthSchemeProvider> authSchemeRegistry = RegistryBuilder.<AuthSchemeProvider>create()
+            .register(AuthSchemes.SPNEGO, nsf)
+            .build();
         this.httpclient = HttpClients.custom()
-            .registerAuthScheme(AuthSchemes.SPNEGO, nsf)
-            .setCredentialsProvider(credentialsProvider)
+            .setDefaultAuthSchemeRegistry(authSchemeRegistry)
+            .setDefaultCredentialsProvider(credentialsProvider)
             .build();
 
         String s = "/path";



Mime
View raw message