maven-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ol...@apache.org
Subject git commit: Wagon HTTP upgraded to HttpClient 4.3
Date Fri, 20 Sep 2013 00:34:02 GMT
Updated Branches:
  refs/heads/master 788920f93 -> a12972eba


Wagon HTTP upgraded to HttpClient 4.3


Project: http://git-wip-us.apache.org/repos/asf/maven-wagon/repo
Commit: http://git-wip-us.apache.org/repos/asf/maven-wagon/commit/a12972eb
Tree: http://git-wip-us.apache.org/repos/asf/maven-wagon/tree/a12972eb
Diff: http://git-wip-us.apache.org/repos/asf/maven-wagon/diff/a12972eb

Branch: refs/heads/master
Commit: a12972eba960cf07505472eebefaede75490bcd9
Parents: 788920f
Author: Oleg Kalnichevski <olegk@apache.org>
Authored: Wed Sep 18 22:06:13 2013 +0200
Committer: Olivier Lamy <olamy@apache.org>
Committed: Fri Sep 20 10:33:51 2013 +1000

----------------------------------------------------------------------
 wagon-providers/pom.xml                         |   4 +-
 .../providers/http/AbstractHttpClientWagon.java | 576 ++++++++++---------
 .../ConfigurableSSLSocketFactoryDecorator.java  |  88 ---
 .../providers/http/HttpMethodConfiguration.java | 137 ++++-
 .../maven/wagon/providers/http/HttpWagon.java   |  69 ++-
 .../providers/http/HttpClientWagonTest.java     |  36 +-
 .../wagon/providers/http/HttpWagonTest.java     |   8 +-
 7 files changed, 462 insertions(+), 456 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/maven-wagon/blob/a12972eb/wagon-providers/pom.xml
----------------------------------------------------------------------
diff --git a/wagon-providers/pom.xml b/wagon-providers/pom.xml
index f3a1c24..c1c2b97 100644
--- a/wagon-providers/pom.xml
+++ b/wagon-providers/pom.xml
@@ -50,12 +50,12 @@ under the License.
       <dependency>
         <groupId>org.apache.httpcomponents</groupId>
         <artifactId>httpclient</artifactId>
-        <version>4.2.5</version>
+        <version>4.3</version>
       </dependency>
       <dependency>
         <groupId>org.apache.httpcomponents</groupId>
         <artifactId>httpcore</artifactId>
-        <version>4.2.4</version>
+        <version>4.3</version>
       </dependency>
       <dependency>
         <groupId>org.apache.sshd</groupId>

http://git-wip-us.apache.org/repos/asf/maven-wagon/blob/a12972eb/wagon-providers/wagon-http/src/main/java/org/apache/maven/wagon/providers/http/AbstractHttpClientWagon.java
----------------------------------------------------------------------
diff --git a/wagon-providers/wagon-http/src/main/java/org/apache/maven/wagon/providers/http/AbstractHttpClientWagon.java b/wagon-providers/wagon-http/src/main/java/org/apache/maven/wagon/providers/http/AbstractHttpClientWagon.java
old mode 100644
new mode 100755
index 6fac842..51e0157
--- a/wagon-providers/wagon-http/src/main/java/org/apache/maven/wagon/providers/http/AbstractHttpClientWagon.java
+++ b/wagon-providers/wagon-http/src/main/java/org/apache/maven/wagon/providers/http/AbstractHttpClientWagon.java
@@ -20,6 +20,7 @@ package org.apache.maven.wagon.providers.http;
  */
 
 import java.io.ByteArrayInputStream;
+import java.io.Closeable;
 import java.io.File;
 import java.io.FileInputStream;
 import java.io.IOException;
@@ -52,33 +53,34 @@ import org.apache.http.auth.Credentials;
 import org.apache.http.auth.NTCredentials;
 import org.apache.http.auth.UsernamePasswordCredentials;
 import org.apache.http.client.AuthCache;
+import org.apache.http.client.CredentialsProvider;
+import org.apache.http.client.config.RequestConfig;
+import org.apache.http.client.methods.CloseableHttpResponse;
 import org.apache.http.client.methods.HttpGet;
 import org.apache.http.client.methods.HttpHead;
 import org.apache.http.client.methods.HttpPut;
 import org.apache.http.client.methods.HttpUriRequest;
-import org.apache.http.client.params.ClientPNames;
-import org.apache.http.client.params.CookiePolicy;
-import org.apache.http.client.protocol.ClientContext;
-import org.apache.http.conn.ClientConnectionManager;
-import org.apache.http.conn.params.ConnRoutePNames;
-import org.apache.http.conn.scheme.PlainSocketFactory;
-import org.apache.http.conn.scheme.Scheme;
-import org.apache.http.conn.scheme.SchemeRegistry;
-import org.apache.http.conn.ssl.SSLSocketFactory;
+import org.apache.http.client.protocol.HttpClientContext;
+import org.apache.http.config.Registry;
+import org.apache.http.config.RegistryBuilder;
+import org.apache.http.conn.HttpClientConnectionManager;
+import org.apache.http.conn.socket.ConnectionSocketFactory;
+import org.apache.http.conn.socket.PlainConnectionSocketFactory;
+import org.apache.http.conn.ssl.SSLConnectionSocketFactory;
 import org.apache.http.conn.ssl.X509HostnameVerifier;
 import org.apache.http.entity.AbstractHttpEntity;
 import org.apache.http.impl.auth.BasicScheme;
 import org.apache.http.impl.client.BasicAuthCache;
-import org.apache.http.impl.client.DefaultHttpClient;
-import org.apache.http.impl.conn.BasicClientConnectionManager;
-import org.apache.http.impl.conn.PoolingClientConnectionManager;
+import org.apache.http.impl.client.BasicCredentialsProvider;
+import org.apache.http.impl.client.CloseableHttpClient;
+import org.apache.http.impl.client.HttpClientBuilder;
+import org.apache.http.impl.conn.BasicHttpClientConnectionManager;
+import org.apache.http.impl.conn.PoolingHttpClientConnectionManager;
 import org.apache.http.impl.cookie.DateParseException;
 import org.apache.http.impl.cookie.DateUtils;
 import org.apache.http.message.BasicHeader;
-import org.apache.http.params.CoreConnectionPNames;
-import org.apache.http.params.CoreProtocolPNames;
-import org.apache.http.params.HttpParams;
-import org.apache.http.protocol.BasicHttpContext;
+import org.apache.http.protocol.HTTP;
+import org.apache.http.util.TextUtils;
 import org.apache.maven.wagon.InputData;
 import org.apache.maven.wagon.OutputData;
 import org.apache.maven.wagon.PathUtils;
@@ -103,8 +105,6 @@ public abstract class AbstractHttpClientWagon
 {
     private static String defaultUserAgent;
 
-    private BasicHttpContext localContext;
-
     private final class RequestEntityImplementation
         extends AbstractHttpEntity
     {
@@ -227,18 +227,22 @@ public abstract class AbstractHttpClientWagon
 
     protected static final TimeZone GMT_TIME_ZONE = TimeZone.getTimeZone( "GMT" );
 
-    private DefaultHttpClient client;
+    private CloseableHttpClient client;
+
+    private HttpClientContext localContext;
+
+    private Closeable closeable;
 
     /**
      * @since 2.0
      */
-    protected static ClientConnectionManager connectionManagerPooled;
+    protected static HttpClientConnectionManager connectionManagerPooled;
 
     /**
      * @since 2.0
      */
-    protected ClientConnectionManager clientConnectionManager =
-        new BasicClientConnectionManager( createSchemeRegistry() );
+    protected HttpClientConnectionManager clientConnectionManager = new BasicHttpClientConnectionManager(
+            createSocketFactoryRegistry() );
 
     /**
      * use http(s) connection pool mechanism.
@@ -276,18 +280,27 @@ public abstract class AbstractHttpClientWagon
     protected static boolean sslAllowAll =
         Boolean.valueOf( System.getProperty( "maven.wagon.http.ssl.allowall", "false" ) );
 
-    private static SchemeRegistry createSchemeRegistry()
+    private static String[] split(final String s) {
+        if (TextUtils.isBlank(s)) {
+            return null;
+        }
+        return s.split(" *, *");
+    }
+
+    private static Registry<ConnectionSocketFactory> createSocketFactoryRegistry()
     {
-        SchemeRegistry schemeRegistry = new SchemeRegistry();
-        schemeRegistry.register( new Scheme( "http", 80, PlainSocketFactory.getSocketFactory() ) );
-        SSLSocketFactory sslSocketFactory;
+        String[] sslProtocols = split(System.getProperty("https.protocols"));
+        String[] cipherSuites = split(System.getProperty("https.cipherSuites"));
+        SSLConnectionSocketFactory sslSocketFactory;
         if ( sslInsecure )
         {
             try
             {
-                sslSocketFactory = new SSLSocketFactory(
-                    RelaxedX509TrustManager.createRelaxedSSLContext(),
-                    sslAllowAll ? new RelaxedHostNameVerifier() : SSLSocketFactory.BROWSER_COMPATIBLE_HOSTNAME_VERIFIER );
+                sslSocketFactory = new SSLConnectionSocketFactory(
+                        RelaxedX509TrustManager.createRelaxedSSLContext(),
+                        sslProtocols,
+                        cipherSuites,
+                        sslAllowAll ? new RelaxedHostNameVerifier() : SSLConnectionSocketFactory.BROWSER_COMPATIBLE_HOSTNAME_VERIFIER );
             }
             catch ( IOException e )
             {
@@ -296,15 +309,16 @@ public abstract class AbstractHttpClientWagon
         }
         else
         {
-            sslSocketFactory = new SSLSocketFactory(
-                HttpsURLConnection.getDefaultSSLSocketFactory(),
-                SSLSocketFactory.BROWSER_COMPATIBLE_HOSTNAME_VERIFIER );
+            sslSocketFactory = new SSLConnectionSocketFactory(
+                    HttpsURLConnection.getDefaultSSLSocketFactory(),
+                    sslProtocols,
+                    cipherSuites,
+                    SSLConnectionSocketFactory.BROWSER_COMPATIBLE_HOSTNAME_VERIFIER );
         }
-
-        Scheme httpsScheme = new Scheme( "https", 443, new ConfigurableSSLSocketFactoryDecorator( sslSocketFactory ) );
-        schemeRegistry.register( httpsScheme );
-
-        return schemeRegistry;
+        return RegistryBuilder.<ConnectionSocketFactory>create()
+                .register("http", PlainConnectionSocketFactory.INSTANCE)
+                .register("https", sslSocketFactory)
+                .build();
     }
 
     static
@@ -315,8 +329,8 @@ public abstract class AbstractHttpClientWagon
         }
         else
         {
-            PoolingClientConnectionManager poolingClientConnectionManager =
-                new PoolingClientConnectionManager( createSchemeRegistry() );
+            PoolingHttpClientConnectionManager poolingClientConnectionManager =
+                new PoolingHttpClientConnectionManager( createSocketFactoryRegistry() );
             int maxPerRoute =
                 Integer.parseInt( System.getProperty( "maven.wagon.httpconnectionManager.maxPerRoute", "20" ) );
             poolingClientConnectionManager.setDefaultMaxPerRoute( maxPerRoute );
@@ -360,7 +374,7 @@ public abstract class AbstractHttpClientWagon
         }
     }
 
-    public ClientConnectionManager getConnectionManager()
+    public HttpClientConnectionManager getConnectionManager()
     {
         if ( !useClientManagerPooled )
         {
@@ -369,7 +383,7 @@ public abstract class AbstractHttpClientWagon
         return connectionManagerPooled;
     }
 
-    public static void setConnectionManagerPooled( ClientConnectionManager clientConnectionManager )
+    public static void setConnectionManagerPooled( HttpClientConnectionManager clientConnectionManager )
     {
         connectionManagerPooled = clientConnectionManager;
     }
@@ -390,15 +404,11 @@ public abstract class AbstractHttpClientWagon
      */
     private HttpConfiguration httpConfiguration;
 
-    private HttpGet getMethod;
-
     public void openConnectionInternal()
     {
         repository.setUrl( getURL( repository ) );
-        client = new DefaultHttpClient( getConnectionManager() );
 
-        // WAGON-273: default the cookie-policy to browser compatible
-        client.getParams().setParameter( ClientPNames.COOKIE_POLICY, CookiePolicy.BROWSER_COMPATIBILITY );
+        CredentialsProvider credentialsProvider = new BasicCredentialsProvider();
 
         if ( authenticationInfo != null )
         {
@@ -413,7 +423,7 @@ public abstract class AbstractHttpClientWagon
                 String host = getRepository().getHost();
                 int port = getRepository().getPort() > -1 ? getRepository().getPort() : AuthScope.ANY_PORT;
 
-                client.getCredentialsProvider().setCredentials( new AuthScope( host, port ), creds );
+                credentialsProvider.setCredentials(new AuthScope(host, port), creds);
                 // preemptive off by default
                 /*
                 AuthCache authCache = new BasicAuthCache();
@@ -428,6 +438,7 @@ public abstract class AbstractHttpClientWagon
             }
         }
 
+        HttpHost proxy = null;
         ProxyInfo proxyInfo = getProxyInfo( getRepository().getProtocol(), getRepository().getHost() );
         if ( proxyInfo != null )
         {
@@ -439,7 +450,7 @@ public abstract class AbstractHttpClientWagon
             String proxyNtlmDomain = proxyInfo.getNtlmDomain();
             if ( proxyHost != null )
             {
-                HttpHost proxy = new HttpHost( proxyHost, proxyPort );
+                proxy = new HttpHost( proxyHost, proxyPort );
 
                 if ( proxyUsername != null && proxyPassword != null )
                 {
@@ -456,12 +467,20 @@ public abstract class AbstractHttpClientWagon
                     int port = proxyInfo.getPort() > -1 ? proxyInfo.getPort() : AuthScope.ANY_PORT;
 
                     AuthScope authScope = new AuthScope( proxyHost, port );
-                    client.getCredentialsProvider().setCredentials( authScope, creds );
+                    credentialsProvider.setCredentials(authScope, creds);
                 }
-
-                client.getParams().setParameter( ConnRoutePNames.DEFAULT_PROXY, proxy );
             }
         }
+
+        localContext = HttpClientContext.create();
+
+        client = HttpClientBuilder.create()
+                .useSystemProperties()
+                .disableConnectionState()
+                .setConnectionManager(getConnectionManager())
+                .setProxy(proxy)
+                .setDefaultCredentialsProvider(credentialsProvider)
+                .build();
     }
 
     public void closeConnection()
@@ -556,8 +575,7 @@ public abstract class AbstractHttpClientWagon
                     new HttpHost( repository.getHost(), repository.getPort(), repository.getProtocol() );
                 authCache.put( targetHost, basicAuth );
 
-                localContext = new BasicHttpContext();
-                localContext.setAttribute( ClientContext.AUTH_CACHE, authCache );
+                localContext.setAuthCache( authCache );
             }
         }
 
@@ -569,73 +587,71 @@ public abstract class AbstractHttpClientWagon
         {
             putMethod.setEntity( httpEntity );
 
-            HttpResponse response;
+            CloseableHttpResponse response = execute( putMethod );
             try
             {
-                response = execute( putMethod );
-            }
-            catch ( IOException e )
-            {
-                fireTransferError( resource, e, TransferEvent.REQUEST_PUT );
-
-                throw new TransferFailedException( e.getMessage(), e );
-            }
-            catch ( HttpException e )
-            {
-                fireTransferError( resource, e, TransferEvent.REQUEST_PUT );
-
-                throw new TransferFailedException( e.getMessage(), e );
-            }
+                int statusCode = response.getStatusLine().getStatusCode();
+                String reasonPhrase = ", ReasonPhrase: " + response.getStatusLine().getReasonPhrase() + ".";
+                fireTransferDebug(url + " - Status code: " + statusCode + reasonPhrase);
 
-            int statusCode = response.getStatusLine().getStatusCode();
-            String reasonPhrase = ", ReasonPhrase: " + response.getStatusLine().getReasonPhrase() + ".";
-            fireTransferDebug( url + " - Status code: " + statusCode + reasonPhrase );
-
-            // Check that we didn't run out of retries.
-            switch ( statusCode )
-            {
-                // Success Codes
-                case HttpStatus.SC_OK: // 200
-                case HttpStatus.SC_CREATED: // 201
-                case HttpStatus.SC_ACCEPTED: // 202
-                case HttpStatus.SC_NO_CONTENT:  // 204
-                    break;
-                // handle all redirect even if http specs says " the user agent MUST NOT automatically redirect the request unless it can be confirmed by the user"
-                case HttpStatus.SC_MOVED_PERMANENTLY: // 301
-                case HttpStatus.SC_MOVED_TEMPORARILY: // 302
-                case HttpStatus.SC_SEE_OTHER: // 303
-                    put( resource, source, httpEntity, calculateRelocatedUrl( response ) );
-                    return;
-                case SC_NULL:
+                // Check that we didn't run out of retries.
+                switch ( statusCode )
                 {
-                    TransferFailedException e =
-                        new TransferFailedException( "Failed to transfer file: " + url + reasonPhrase );
-                    fireTransferError( resource, e, TransferEvent.REQUEST_PUT );
-                    throw e;
-                }
+                    // Success Codes
+                    case HttpStatus.SC_OK: // 200
+                    case HttpStatus.SC_CREATED: // 201
+                    case HttpStatus.SC_ACCEPTED: // 202
+                    case HttpStatus.SC_NO_CONTENT:  // 204
+                        break;
+                    // handle all redirect even if http specs says " the user agent MUST NOT automatically redirect the request unless it can be confirmed by the user"
+                    case HttpStatus.SC_MOVED_PERMANENTLY: // 301
+                    case HttpStatus.SC_MOVED_TEMPORARILY: // 302
+                    case HttpStatus.SC_SEE_OTHER: // 303
+                        put( resource, source, httpEntity, calculateRelocatedUrl( response ) );
+                        return;
+                    case SC_NULL:
+                    {
+                        TransferFailedException e =
+                            new TransferFailedException( "Failed to transfer file: " + url + reasonPhrase );
+                        fireTransferError( resource, e, TransferEvent.REQUEST_PUT );
+                        throw e;
+                    }
 
-                case HttpStatus.SC_FORBIDDEN:
-                    fireSessionConnectionRefused();
-                    throw new AuthorizationException( "Access denied to: " + url + reasonPhrase );
+                    case HttpStatus.SC_FORBIDDEN:
+                        fireSessionConnectionRefused();
+                        throw new AuthorizationException( "Access denied to: " + url + reasonPhrase );
 
-                case HttpStatus.SC_NOT_FOUND:
-                    throw new ResourceDoesNotExistException( "File: " + url + " does not exist" + reasonPhrase );
+                    case HttpStatus.SC_NOT_FOUND:
+                        throw new ResourceDoesNotExistException( "File: " + url + " does not exist" + reasonPhrase );
 
-                    //add more entries here
-                default:
-                {
-                    TransferFailedException e = new TransferFailedException(
-                        "Failed to transfer file: " + url + ". Return code is: " + statusCode + reasonPhrase );
-                    fireTransferError( resource, e, TransferEvent.REQUEST_PUT );
-                    throw e;
+                        //add more entries here
+                    default:
+                    {
+                        TransferFailedException e = new TransferFailedException(
+                            "Failed to transfer file: " + url + ". Return code is: " + statusCode + reasonPhrase );
+                        fireTransferError( resource, e, TransferEvent.REQUEST_PUT );
+                        throw e;
+                    }
                 }
+
+                firePutCompleted(resource, source);
+            }
+            finally
+            {
+                response.close();
             }
+        }
+        catch ( IOException e )
+        {
+            fireTransferError( resource, e, TransferEvent.REQUEST_PUT );
 
-            firePutCompleted( resource, source );
+            throw new TransferFailedException( e.getMessage(), e );
         }
-        finally
+        catch ( HttpException e )
         {
-            putMethod.abort();
+            fireTransferError( resource, e, TransferEvent.REQUEST_PUT );
+
+            throw new TransferFailedException( e.getMessage(), e );
         }
     }
 
@@ -659,11 +675,46 @@ public abstract class AbstractHttpClientWagon
         String repositoryUrl = getRepository().getUrl();
         String url = repositoryUrl + ( repositoryUrl.endsWith( "/" ) ? "" : "/" ) + resourceName;
         HttpHead headMethod = new HttpHead( url );
-        HttpResponse response = null;
-        int statusCode;
         try
         {
-            response = execute( headMethod );
+            CloseableHttpResponse response = execute( headMethod );
+            try {
+                int statusCode = response.getStatusLine().getStatusCode();
+                String reasonPhrase = ", ReasonPhrase: " + response.getStatusLine().getReasonPhrase() + ".";
+                switch ( statusCode )
+                {
+                    case HttpStatus.SC_OK:
+                        return true;
+
+                    case HttpStatus.SC_NOT_MODIFIED:
+                        return true;
+
+                    case SC_NULL:
+                        throw new TransferFailedException( "Failed to transfer file: " + url + reasonPhrase );
+
+                    case HttpStatus.SC_FORBIDDEN:
+                        throw new AuthorizationException( "Access denied to: " + url + reasonPhrase );
+
+                    case HttpStatus.SC_UNAUTHORIZED:
+                        throw new AuthorizationException( "Not authorized " + reasonPhrase );
+
+                    case HttpStatus.SC_PROXY_AUTHENTICATION_REQUIRED:
+                        throw new AuthorizationException( "Not authorized by proxy " + reasonPhrase );
+
+                    case HttpStatus.SC_NOT_FOUND:
+                        return false;
+
+                    //add more entries here
+                    default:
+                        throw new TransferFailedException(
+                            "Failed to transfer file: " + url + ". Return code is: " + statusCode + reasonPhrase );
+                }
+
+            }
+            finally
+            {
+                response.close();
+            }
         }
         catch ( IOException e )
         {
@@ -673,52 +724,49 @@ public abstract class AbstractHttpClientWagon
         {
             throw new TransferFailedException( e.getMessage(), e );
         }
+    }
 
-        try
-        {
-            statusCode = response.getStatusLine().getStatusCode();
-            String reasonPhrase = ", ReasonPhrase: " + response.getStatusLine().getReasonPhrase() + ".";
-            switch ( statusCode )
-            {
-                case HttpStatus.SC_OK:
-                    return true;
-
-                case HttpStatus.SC_NOT_MODIFIED:
-                    return true;
+    protected CloseableHttpResponse execute( HttpUriRequest httpMethod)
+        throws HttpException, IOException
+    {
+        setHeaders( httpMethod );
+        String userAgent = getUserAgent( httpMethod );
+        if (userAgent != null) {
+            httpMethod.setHeader(HTTP.USER_AGENT, userAgent);
+        }
 
-                case SC_NULL:
-                    throw new TransferFailedException( "Failed to transfer file: " + url + reasonPhrase );
+        HttpMethodConfiguration config =
+            httpConfiguration == null ? null : httpConfiguration.getMethodConfiguration( httpMethod );
+        if ( config != null )
+        {
+            localContext.setRequestConfig( config.asRequestConfig() );
 
-                case HttpStatus.SC_FORBIDDEN:
-                    throw new AuthorizationException( "Access denied to: " + url + reasonPhrase );
+            if ( config.isUsePreemptive() && authenticationInfo != null )
+            {
+                String username = authenticationInfo.getUserName();
+                String password = authenticationInfo.getPassword();
 
-                case HttpStatus.SC_UNAUTHORIZED:
-                    throw new AuthorizationException( "Not authorized " + reasonPhrase );
+                if ( StringUtils.isNotEmpty( username ) && StringUtils.isNotEmpty( password ) )
+                {
 
-                case HttpStatus.SC_PROXY_AUTHENTICATION_REQUIRED:
-                    throw new AuthorizationException( "Not authorized by proxy " + reasonPhrase );
+                    AuthCache authCache = new BasicAuthCache();
+                    BasicScheme basicAuth = new BasicScheme();
+                    HttpHost targetHost =
+                        new HttpHost( repository.getHost(), repository.getPort(), repository.getProtocol() );
+                    authCache.put( targetHost, basicAuth );
 
-                case HttpStatus.SC_NOT_FOUND:
-                    return false;
+                    localContext.setAuthCache( authCache );
+                }
 
-                //add more entries here
-                default:
-                    throw new TransferFailedException(
-                        "Failed to transfer file: " + url + ". Return code is: " + statusCode + reasonPhrase );
             }
         }
-        finally
+        else
         {
-            headMethod.abort();
+            RequestConfig requestConfig = RequestConfig.custom()
+                    .setSocketTimeout( getReadTimeout() )
+                    .build();
+            localContext.setRequestConfig( requestConfig );
         }
-    }
-
-    protected HttpResponse execute( HttpUriRequest httpMethod )
-        throws HttpException, IOException
-    {
-        setParameters( httpMethod );
-        setHeaders( httpMethod );
-        client.getParams().setParameter( CoreProtocolPNames.USER_AGENT, getUserAgent( httpMethod ) );
 
         ProxyInfo proxyInfo = getProxyInfo( getRepository().getProtocol(), getRepository().getHost() );
 
@@ -747,47 +795,6 @@ public abstract class AbstractHttpClientWagon
         return client.execute( httpMethod, localContext );
     }
 
-    protected void setParameters( HttpUriRequest method )
-    {
-        HttpMethodConfiguration config =
-            httpConfiguration == null ? null : httpConfiguration.getMethodConfiguration( method );
-        if ( config != null )
-        {
-            HttpParams params = config.asMethodParams( method.getParams() );
-
-            if ( config.isUsePreemptive() && authenticationInfo != null )
-            {
-                String username = authenticationInfo.getUserName();
-                String password = authenticationInfo.getPassword();
-
-                if ( StringUtils.isNotEmpty( username ) && StringUtils.isNotEmpty( password ) )
-                {
-
-                    AuthCache authCache = new BasicAuthCache();
-                    BasicScheme basicAuth = new BasicScheme();
-                    HttpHost targetHost =
-                        new HttpHost( repository.getHost(), repository.getPort(), repository.getProtocol() );
-                    authCache.put( targetHost, basicAuth );
-
-                    localContext = new BasicHttpContext();
-                    localContext.setAttribute( ClientContext.AUTH_CACHE, authCache );
-                }
-
-            }
-
-            if ( params != null )
-            {
-                method.setParams( params );
-            }
-        }
-
-        if ( config == null )
-        {
-            int readTimeout = getReadTimeout();
-            method.getParams().setParameter( CoreConnectionPNames.SO_TIMEOUT, readTimeout );
-        }
-    }
-
     protected void setHeaders( HttpUriRequest method )
     {
         HttpMethodConfiguration config =
@@ -902,7 +909,7 @@ public abstract class AbstractHttpClientWagon
 
         String repositoryUrl = getRepository().getUrl();
         String url = repositoryUrl + ( repositoryUrl.endsWith( "/" ) ? "" : "/" ) + resource.getName();
-        getMethod = new HttpGet( url );
+        HttpGet getMethod = new HttpGet( url );
         long timestamp = resource.getLastModified();
         if ( timestamp > 0 )
         {
@@ -913,145 +920,150 @@ public abstract class AbstractHttpClientWagon
             getMethod.addHeader( hdr );
         }
 
-        HttpResponse response;
-        int statusCode;
         try
         {
-            response = execute( getMethod );
-        }
-        catch ( IOException e )
-        {
-            fireTransferError( resource, e, TransferEvent.REQUEST_GET );
+            CloseableHttpResponse response = execute( getMethod );
+            closeable = response;
+            int statusCode = response.getStatusLine().getStatusCode();
 
-            throw new TransferFailedException( e.getMessage(), e );
-        }
-        catch ( HttpException e )
-        {
-            fireTransferError( resource, e, TransferEvent.REQUEST_GET );
+            String reasonPhrase = ", ReasonPhrase:" + response.getStatusLine().getReasonPhrase() + ".";
 
-            throw new TransferFailedException( e.getMessage(), e );
-        }
+            fireTransferDebug( url + " - Status code: " + statusCode + reasonPhrase );
 
-        statusCode = response.getStatusLine().getStatusCode();
+            // TODO [BP]: according to httpclient docs, really should swallow the output on error. verify if that is
+            // required
+            switch ( statusCode )
+            {
+                case HttpStatus.SC_OK:
+                    break;
 
-        String reasonPhrase = ", ReasonPhrase:" + response.getStatusLine().getReasonPhrase() + ".";
+                case HttpStatus.SC_NOT_MODIFIED:
+                    // return, leaving last modified set to original value so getIfNewer should return unmodified
+                    return;
 
-        fireTransferDebug( url + " - Status code: " + statusCode + reasonPhrase );
+                case SC_NULL:
+                {
+                    TransferFailedException e =
+                        new TransferFailedException( "Failed to transfer file: " + url + " " + reasonPhrase );
+                    fireTransferError( resource, e, TransferEvent.REQUEST_GET );
+                    throw e;
+                }
 
-        // TODO [BP]: according to httpclient docs, really should swallow the output on error. verify if that is
-        // required
-        switch ( statusCode )
-        {
-            case HttpStatus.SC_OK:
-                break;
+                case HttpStatus.SC_FORBIDDEN:
+                    fireSessionConnectionRefused();
+                    throw new AuthorizationException( "Access denied to: " + url + " " + reasonPhrase );
 
-            case HttpStatus.SC_NOT_MODIFIED:
-                // return, leaving last modified set to original value so getIfNewer should return unmodified
-                return;
+                case HttpStatus.SC_UNAUTHORIZED:
+                    fireSessionConnectionRefused();
+                    throw new AuthorizationException( "Not authorized " + reasonPhrase );
 
-            case SC_NULL:
-            {
-                TransferFailedException e =
-                    new TransferFailedException( "Failed to transfer file: " + url + " " + reasonPhrase );
-                fireTransferError( resource, e, TransferEvent.REQUEST_GET );
-                throw e;
-            }
+                case HttpStatus.SC_PROXY_AUTHENTICATION_REQUIRED:
+                    fireSessionConnectionRefused();
+                    throw new AuthorizationException( "Not authorized by proxy " + reasonPhrase );
 
-            case HttpStatus.SC_FORBIDDEN:
-                fireSessionConnectionRefused();
-                throw new AuthorizationException( "Access denied to: " + url + " " + reasonPhrase );
+                case HttpStatus.SC_NOT_FOUND:
+                    throw new ResourceDoesNotExistException( "File: " + url + " " + reasonPhrase );
 
-            case HttpStatus.SC_UNAUTHORIZED:
-                fireSessionConnectionRefused();
-                throw new AuthorizationException( "Not authorized " + reasonPhrase );
+                    // add more entries here
+                default:
+                {
+                    cleanupGetTransfer( resource );
+                    TransferFailedException e = new TransferFailedException(
+                        "Failed to transfer file: " + url + ". Return code is: " + statusCode + " " + reasonPhrase );
+                    fireTransferError( resource, e, TransferEvent.REQUEST_GET );
+                    throw e;
+                }
+            }
 
-            case HttpStatus.SC_PROXY_AUTHENTICATION_REQUIRED:
-                fireSessionConnectionRefused();
-                throw new AuthorizationException( "Not authorized by proxy " + reasonPhrase );
+            InputStream is;
 
-            case HttpStatus.SC_NOT_FOUND:
-                throw new ResourceDoesNotExistException( "File: " + url + " " + reasonPhrase );
+            Header contentLengthHeader = response.getFirstHeader( "Content-Length" );
 
-                // add more entries here
-            default:
+            if ( contentLengthHeader != null )
             {
-                cleanupGetTransfer( resource );
-                TransferFailedException e = new TransferFailedException(
-                    "Failed to transfer file: " + url + ". Return code is: " + statusCode + " " + reasonPhrase );
-                fireTransferError( resource, e, TransferEvent.REQUEST_GET );
-                throw e;
+                try
+                {
+                    long contentLength = Long.parseLong( contentLengthHeader.getValue() );
+
+                    resource.setContentLength( contentLength );
+                }
+                catch ( NumberFormatException e )
+                {
+                    fireTransferDebug(
+                        "error parsing content length header '" + contentLengthHeader.getValue() + "' " + e );
+                }
             }
-        }
 
-        InputStream is;
+            Header lastModifiedHeader = response.getFirstHeader( "Last-Modified" );
 
-        Header contentLengthHeader = response.getFirstHeader( "Content-Length" );
+            long lastModified = 0;
 
-        if ( contentLengthHeader != null )
-        {
-            try
+            if ( lastModifiedHeader != null )
             {
-                long contentLength = Long.parseLong( contentLengthHeader.getValue() );
+                try
+                {
+                    lastModified = DateUtils.parseDate( lastModifiedHeader.getValue() ).getTime();
 
-                resource.setContentLength( contentLength );
-            }
-            catch ( NumberFormatException e )
-            {
-                fireTransferDebug(
-                    "error parsing content length header '" + contentLengthHeader.getValue() + "' " + e );
-            }
-        }
+                    resource.setLastModified( lastModified );
+                }
+                catch ( DateParseException e )
+                {
+                    fireTransferDebug( "Unable to parse last modified header" );
+                }
 
-        Header lastModifiedHeader = response.getFirstHeader( "Last-Modified" );
+                fireTransferDebug( "last-modified = " + lastModifiedHeader.getValue() + " (" + lastModified + ")" );
+            }
 
-        long lastModified = 0;
+            Header contentEncoding = response.getFirstHeader( "Content-Encoding" );
+            boolean isGZipped = contentEncoding == null ? false : "gzip".equalsIgnoreCase( contentEncoding.getValue() );
 
-        if ( lastModifiedHeader != null )
-        {
             try
             {
-                lastModified = DateUtils.parseDate( lastModifiedHeader.getValue() ).getTime();
+                is = response.getEntity().getContent();
 
-                resource.setLastModified( lastModified );
+                if ( isGZipped )
+                {
+                    is = new GZIPInputStream( is );
+                }
             }
-            catch ( DateParseException e )
+            catch ( IOException e )
             {
-                fireTransferDebug( "Unable to parse last modified header" );
-            }
-
-            fireTransferDebug( "last-modified = " + lastModifiedHeader.getValue() + " (" + lastModified + ")" );
-        }
+                fireTransferError( resource, e, TransferEvent.REQUEST_GET );
 
-        Header contentEncoding = response.getFirstHeader( "Content-Encoding" );
-        boolean isGZipped = contentEncoding == null ? false : "gzip".equalsIgnoreCase( contentEncoding.getValue() );
+                String msg =
+                    "Error occurred while retrieving from remote repository " + getRepository() + ": " + e.getMessage();
 
-        try
-        {
-            is = response.getEntity().getContent();
-
-            if ( isGZipped )
-            {
-                is = new GZIPInputStream( is );
+                throw new TransferFailedException( msg, e );
             }
+
+            inputData.setInputStream( is );
         }
         catch ( IOException e )
         {
             fireTransferError( resource, e, TransferEvent.REQUEST_GET );
 
-            String msg =
-                "Error occurred while retrieving from remote repository " + getRepository() + ": " + e.getMessage();
-
-            throw new TransferFailedException( msg, e );
+            throw new TransferFailedException( e.getMessage(), e );
         }
+        catch ( HttpException e )
+        {
+            fireTransferError( resource, e, TransferEvent.REQUEST_GET );
 
-        inputData.setInputStream( is );
+            throw new TransferFailedException( e.getMessage(), e );
+        }
     }
 
     protected void cleanupGetTransfer( Resource resource )
     {
-        if ( getMethod != null )
+        if ( closeable != null )
         {
-            getMethod.abort();
+            try
+            {
+                closeable.close();
+            }
+            catch (IOException ignore)
+            {
+            }
+
         }
     }
 

http://git-wip-us.apache.org/repos/asf/maven-wagon/blob/a12972eb/wagon-providers/wagon-http/src/main/java/org/apache/maven/wagon/providers/http/ConfigurableSSLSocketFactoryDecorator.java
----------------------------------------------------------------------
diff --git a/wagon-providers/wagon-http/src/main/java/org/apache/maven/wagon/providers/http/ConfigurableSSLSocketFactoryDecorator.java b/wagon-providers/wagon-http/src/main/java/org/apache/maven/wagon/providers/http/ConfigurableSSLSocketFactoryDecorator.java
deleted file mode 100644
index d3ab658..0000000
--- a/wagon-providers/wagon-http/src/main/java/org/apache/maven/wagon/providers/http/ConfigurableSSLSocketFactoryDecorator.java
+++ /dev/null
@@ -1,88 +0,0 @@
-package org.apache.maven.wagon.providers.http;
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-import java.io.IOException;
-import java.net.InetSocketAddress;
-import java.net.Socket;
-import java.net.UnknownHostException;
-
-import javax.net.ssl.SSLSocket;
-
-import org.apache.http.conn.ConnectTimeoutException;
-import org.apache.http.conn.scheme.SchemeLayeredSocketFactory;
-import org.apache.http.params.HttpParams;
-import org.codehaus.plexus.util.StringUtils;
-
-/**
- * @since 2.4
- */
-class ConfigurableSSLSocketFactoryDecorator
-    implements SchemeLayeredSocketFactory
-{
-
-    private final SchemeLayeredSocketFactory sslSocketFactory;
-
-    public ConfigurableSSLSocketFactoryDecorator( SchemeLayeredSocketFactory sslSocketFactory )
-    {
-        super();
-        this.sslSocketFactory = sslSocketFactory;
-    }
-
-    public Socket createSocket( final HttpParams params )
-        throws IOException
-    {
-        return enableSslProtocols( this.sslSocketFactory.createSocket( params ) );
-    }
-
-    public Socket createLayeredSocket( final Socket socket, final String target, int port, final HttpParams params )
-        throws IOException, UnknownHostException
-    {
-        return enableSslProtocols( this.sslSocketFactory.createLayeredSocket( socket, target, port, params ) );
-    }
-
-    public Socket connectSocket( final Socket sock, final InetSocketAddress remoteAddress,
-                                 final InetSocketAddress localAddress, final HttpParams params )
-        throws IOException, UnknownHostException, ConnectTimeoutException
-    {
-        return this.sslSocketFactory.connectSocket( sock, remoteAddress, localAddress, params );
-    }
-
-    public boolean isSecure( final Socket sock )
-        throws IllegalArgumentException
-    {
-        return this.sslSocketFactory.isSecure( sock );
-    }
-
-    protected Socket enableSslProtocols( Socket socket )
-    {
-        String httpsProtocols = System.getProperty( "https.protocols" );
-        if ( StringUtils.isNotEmpty( httpsProtocols ) )
-        {
-            String[] protocols = StringUtils.split( httpsProtocols, "," );
-            if ( socket instanceof SSLSocket )
-            {
-                ( (SSLSocket) socket ).setEnabledProtocols( protocols );
-            }
-        }
-
-        return socket;
-    }
-
-}

http://git-wip-us.apache.org/repos/asf/maven-wagon/blob/a12972eb/wagon-providers/wagon-http/src/main/java/org/apache/maven/wagon/providers/http/HttpMethodConfiguration.java
----------------------------------------------------------------------
diff --git a/wagon-providers/wagon-http/src/main/java/org/apache/maven/wagon/providers/http/HttpMethodConfiguration.java b/wagon-providers/wagon-http/src/main/java/org/apache/maven/wagon/providers/http/HttpMethodConfiguration.java
old mode 100644
new mode 100755
index 8fb01e1..3be9837
--- a/wagon-providers/wagon-http/src/main/java/org/apache/maven/wagon/providers/http/HttpMethodConfiguration.java
+++ b/wagon-providers/wagon-http/src/main/java/org/apache/maven/wagon/providers/http/HttpMethodConfiguration.java
@@ -19,15 +19,10 @@ package org.apache.maven.wagon.providers.http;
  * under the License.
  */
 
-import org.apache.http.Header;
-import org.apache.http.message.BasicHeader;
-import org.apache.http.params.BasicHttpParams;
-import org.apache.http.params.CoreConnectionPNames;
-import org.apache.http.params.DefaultedHttpParams;
-import org.apache.http.params.HttpParams;
-import org.apache.maven.wagon.Wagon;
-
+import java.net.InetAddress;
+import java.net.UnknownHostException;
 import java.util.ArrayList;
+import java.util.Arrays;
 import java.util.Iterator;
 import java.util.LinkedHashMap;
 import java.util.List;
@@ -36,11 +31,18 @@ import java.util.Properties;
 import java.util.regex.Matcher;
 import java.util.regex.Pattern;
 
+import org.apache.http.Header;
+import org.apache.http.HttpHost;
+import org.apache.http.client.config.CookieSpecs;
+import org.apache.http.client.config.RequestConfig;
+import org.apache.http.message.BasicHeader;
+import org.apache.http.params.CoreConnectionPNames;
+import org.apache.http.params.HttpParams;
+import org.apache.maven.wagon.Wagon;
+
 public class HttpMethodConfiguration
 {
 
-    private static final String COERCE_PATTERN = "%(\\w+),(.+)";
-
     private Boolean useDefaultHeaders;
 
     private Properties headers = new Properties();
@@ -126,18 +128,123 @@ public class HttpMethodConfiguration
         return this;
     }
 
-    public HttpParams asMethodParams( HttpParams defaults )
+    private static final String SO_TIMEOUT                  = "http.socket.timeout";
+    private static final String STALE_CONNECTION_CHECK      = "http.connection.stalecheck";
+    private static final String CONNECTION_TIMEOUT          = "http.connection.timeout";
+    private static final String USE_EXPECT_CONTINUE         = "http.protocol.expect-continue";
+    private static final String DEFAULT_PROXY               = "http.route.default-proxy";
+    private static final String LOCAL_ADDRESS               = "http.route.local-address";
+    private static final String PROXY_AUTH_PREF             = "http.auth.proxy-scheme-pref";
+    private static final String TARGET_AUTH_PREF            = "http.auth.target-scheme-pref";
+    private static final String HANDLE_AUTHENTICATION       = "http.protocol.handle-authentication";
+    private static final String ALLOW_CIRCULAR_REDIRECTS    = "http.protocol.allow-circular-redirects";
+    private static final String CONN_MANAGER_TIMEOUT        = "http.conn-manager.timeout";
+    private static final String COOKIE_POLICY               = "http.protocol.cookie-policy";
+    private static final String MAX_REDIRECTS               = "http.protocol.max-redirects";
+    private static final String HANDLE_REDIRECTS            = "http.protocol.handle-redirects";
+    private static final String REJECT_RELATIVE_REDIRECT    = "http.protocol.reject-relative-redirect";
+
+    private static final String COERCE_PATTERN = "%(\\w+),(.+)";
+
+    public RequestConfig asRequestConfig()
     {
         if ( !hasParams() )
         {
             return null;
         }
+        RequestConfig.Builder builder = RequestConfig.custom();
+        // WAGON-273: default the cookie-policy to browser compatible
+        builder.setCookieSpec(CookieSpecs.BROWSER_COMPATIBILITY);
+        if ( connectionTimeout > 0 )
+        {
+            builder.setConnectTimeout(connectionTimeout);
+        }
+        if ( readTimeout > 0 )
+        {
+            builder.setSocketTimeout(readTimeout);
+        }
+        if ( params != null )
+        {
 
-        DefaultedHttpParams p = new DefaultedHttpParams( new BasicHttpParams(), defaults );
-
-        fillParams( p );
+            Pattern coercePattern = Pattern.compile( COERCE_PATTERN );
+            for ( Iterator<?> it = params.entrySet().iterator(); it.hasNext(); )
+            {
+                Map.Entry<String, String> entry = (Map.Entry) it.next();
+                String key = entry.getKey();
+                String value = entry.getValue();
+                Matcher matcher = coercePattern.matcher(value);
+                if ( matcher.matches() )
+                {
+                    value = matcher.group( 2 );
+                }
 
-        return p;
+                if ( key.equals( SO_TIMEOUT ) )
+                {
+                    builder.setSocketTimeout( Integer.parseInt( value ) );
+                }
+                else if ( key.equals( STALE_CONNECTION_CHECK ) )
+                {
+                    builder.setStaleConnectionCheckEnabled( Boolean.valueOf( value ) );
+                }
+                else if ( key.equals( CONNECTION_TIMEOUT ) )
+                {
+                    builder.setConnectTimeout( Integer.parseInt( value ) );
+                }
+                else if ( key.equals( USE_EXPECT_CONTINUE ) )
+                {
+                    builder.setExpectContinueEnabled( Boolean.valueOf( value ) );
+                }
+                else if ( key.equals( DEFAULT_PROXY ) )
+                {
+                    builder.setProxy( new HttpHost( value ));
+                }
+                else if ( key.equals( LOCAL_ADDRESS ) )
+                {
+                    try {
+                        builder.setLocalAddress( InetAddress.getByName( value ) );
+                    }
+                    catch (UnknownHostException ignore) {
+                    }
+                }
+                else if ( key.equals( PROXY_AUTH_PREF ) )
+                {
+                    builder.setProxyPreferredAuthSchemes( Arrays.asList( value.split( "," ) ) );
+                }
+                else if ( key.equals( TARGET_AUTH_PREF ) )
+                {
+                    builder.setTargetPreferredAuthSchemes( Arrays.asList( value.split( "," ) ) );
+                }
+                else if ( key.equals( HANDLE_AUTHENTICATION ) )
+                {
+                    builder.setAuthenticationEnabled( Boolean.valueOf( value ) );
+                }
+                else if ( key.equals( ALLOW_CIRCULAR_REDIRECTS ) )
+                {
+                    builder.setCircularRedirectsAllowed( Boolean.valueOf( value ) );
+                }
+                else if ( key.equals( CONN_MANAGER_TIMEOUT ) )
+                {
+                    builder.setConnectionRequestTimeout( Integer.parseInt( value ) );
+                }
+                else if ( key.equals( COOKIE_POLICY ) )
+                {
+                    builder.setCookieSpec( value );
+                }
+                else if ( key.equals( MAX_REDIRECTS ) )
+                {
+                    builder.setMaxRedirects( Integer.parseInt( value ) );
+                }
+                else if ( key.equals( HANDLE_REDIRECTS ) )
+                {
+                    builder.setRedirectsEnabled( Boolean.valueOf( value ) );
+                }
+                else if ( key.equals( REJECT_RELATIVE_REDIRECT ) )
+                {
+                    builder.setRelativeRedirectsAllowed( !Boolean.valueOf( value ) );
+                }
+            }
+        }
+        return builder.build();
     }
 
     private boolean hasParams()

http://git-wip-us.apache.org/repos/asf/maven-wagon/blob/a12972eb/wagon-providers/wagon-http/src/main/java/org/apache/maven/wagon/providers/http/HttpWagon.java
----------------------------------------------------------------------
diff --git a/wagon-providers/wagon-http/src/main/java/org/apache/maven/wagon/providers/http/HttpWagon.java b/wagon-providers/wagon-http/src/main/java/org/apache/maven/wagon/providers/http/HttpWagon.java
old mode 100644
new mode 100755
index acc8533..68fad2c
--- a/wagon-providers/wagon-http/src/main/java/org/apache/maven/wagon/providers/http/HttpWagon.java
+++ b/wagon-providers/wagon-http/src/main/java/org/apache/maven/wagon/providers/http/HttpWagon.java
@@ -19,19 +19,19 @@ package org.apache.maven.wagon.providers.http;
  * under the License.
  */
 
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.List;
+
 import org.apache.http.HttpException;
-import org.apache.http.HttpResponse;
 import org.apache.http.HttpStatus;
+import org.apache.http.client.methods.CloseableHttpResponse;
 import org.apache.http.client.methods.HttpGet;
 import org.apache.maven.wagon.ResourceDoesNotExistException;
 import org.apache.maven.wagon.TransferFailedException;
 import org.apache.maven.wagon.authorization.AuthorizationException;
 import org.apache.maven.wagon.shared.http.HtmlFileListParser;
 
-import java.io.IOException;
-import java.io.InputStream;
-import java.util.List;
-
 /**
  * @author <a href="michal.maczka@dimatics.com">Michal Maczka</a>
  *
@@ -53,42 +53,45 @@ public class HttpWagon
 
         try
         {
+            CloseableHttpResponse response = execute( getMethod );
+            try {
+                int statusCode = response.getStatusLine().getStatusCode();
 
-            HttpResponse response = execute( getMethod );
-            int statusCode = response.getStatusLine().getStatusCode();
-
-            fireTransferDebug( url + " - Status code: " + statusCode );
+                fireTransferDebug( url + " - Status code: " + statusCode );
 
-            // TODO [BP]: according to httpclient docs, really should swallow the output on error. verify if that is required
-            switch ( statusCode )
-            {
-                case HttpStatus.SC_OK:
-                    break;
+                // TODO [BP]: according to httpclient docs, really should swallow the output on error. verify if that is required
+                switch ( statusCode )
+                {
+                    case HttpStatus.SC_OK:
+                        break;
 
-                case SC_NULL:
-                    throw new TransferFailedException( "Failed to transfer file: " );
+                    case SC_NULL:
+                        throw new TransferFailedException( "Failed to transfer file: " );
 
-                case HttpStatus.SC_FORBIDDEN:
-                    throw new AuthorizationException( "Access denied to: " + url );
+                    case HttpStatus.SC_FORBIDDEN:
+                        throw new AuthorizationException( "Access denied to: " + url );
 
-                case HttpStatus.SC_UNAUTHORIZED:
-                    throw new AuthorizationException( "Not authorized." );
+                    case HttpStatus.SC_UNAUTHORIZED:
+                        throw new AuthorizationException( "Not authorized." );
 
-                case HttpStatus.SC_PROXY_AUTHENTICATION_REQUIRED:
-                    throw new AuthorizationException( "Not authorized by proxy." );
+                    case HttpStatus.SC_PROXY_AUTHENTICATION_REQUIRED:
+                        throw new AuthorizationException( "Not authorized by proxy." );
 
-                case HttpStatus.SC_NOT_FOUND:
-                    throw new ResourceDoesNotExistException( "File: " + url + " does not exist" );
+                    case HttpStatus.SC_NOT_FOUND:
+                        throw new ResourceDoesNotExistException( "File: " + url + " does not exist" );
 
-                    //add more entries here
-                default:
-                    throw new TransferFailedException(
-                        "Failed to transfer file: " + url + ". Return code is: " + statusCode );
-            }
+                        //add more entries here
+                    default:
+                        throw new TransferFailedException(
+                            "Failed to transfer file: " + url + ". Return code is: " + statusCode );
+                }
 
-            InputStream is = response.getEntity().getContent();
+                InputStream is = response.getEntity().getContent();
 
-            return HtmlFileListParser.parseFileList( url, is );
+                return HtmlFileListParser.parseFileList( url, is );
+            } finally {
+                response.close();
+            }
         }
         catch ( IOException e )
         {
@@ -98,9 +101,5 @@ public class HttpWagon
         {
             throw new TransferFailedException( "Could not read response body.", e );
         }
-        finally
-        {
-            getMethod.abort();
-        }
     }
 }

http://git-wip-us.apache.org/repos/asf/maven-wagon/blob/a12972eb/wagon-providers/wagon-http/src/test/java/org/apache/maven/wagon/providers/http/HttpClientWagonTest.java
----------------------------------------------------------------------
diff --git a/wagon-providers/wagon-http/src/test/java/org/apache/maven/wagon/providers/http/HttpClientWagonTest.java b/wagon-providers/wagon-http/src/test/java/org/apache/maven/wagon/providers/http/HttpClientWagonTest.java
old mode 100644
new mode 100755
index c70f1a3..95683cd
--- a/wagon-providers/wagon-http/src/test/java/org/apache/maven/wagon/providers/http/HttpClientWagonTest.java
+++ b/wagon-providers/wagon-http/src/test/java/org/apache/maven/wagon/providers/http/HttpClientWagonTest.java
@@ -21,10 +21,10 @@ package org.apache.maven.wagon.providers.http;
 
 
 import junit.framework.TestCase;
+
 import org.apache.http.Header;
+import org.apache.http.client.config.RequestConfig;
 import org.apache.http.client.methods.HttpHead;
-import org.apache.http.client.params.ClientPNames;
-import org.apache.http.params.HttpParams;
 import org.apache.maven.wagon.OutputData;
 import org.apache.maven.wagon.TransferFailedException;
 
@@ -32,43 +32,19 @@ public class HttpClientWagonTest
     extends TestCase
 {
 
-    public void testSetPreemptiveAuthParamViaConfig()
-    {
-        HttpMethodConfiguration methodConfig = new HttpMethodConfiguration();
-        //X TODO methodConfig.addParam( HttpClientParams.PREEMPTIVE_AUTHENTICATION, "%b,true" );
-
-        HttpConfiguration config = new HttpConfiguration();
-        config.setAll( methodConfig );
-
-        TestWagon wagon = new TestWagon();
-        wagon.setHttpConfiguration( config );
-
-        HttpHead method = new HttpHead();
-        wagon.setParameters( method );
-
-        HttpParams params = method.getParams();
-        assertNotNull( params );
-        //X TODO assertTrue( params.isParameterTrue( HttpClientParams.PREEMPTIVE_AUTHENTICATION ) );
-    }
-
     public void testSetMaxRedirectsParamViaConfig()
     {
         HttpMethodConfiguration methodConfig = new HttpMethodConfiguration();
         int maxRedirects = 2;
-        methodConfig.addParam( ClientPNames.MAX_REDIRECTS, "%i," + maxRedirects );
+        methodConfig.addParam("http.protocol.max-redirects", "%i," + maxRedirects);
 
         HttpConfiguration config = new HttpConfiguration();
-        config.setAll( methodConfig );
-
-        TestWagon wagon = new TestWagon();
-        wagon.setHttpConfiguration( config );
+        config.setAll(methodConfig);
 
         HttpHead method = new HttpHead();
-        wagon.setParameters( method );
+        RequestConfig requestConfig = config.getMethodConfiguration(method).asRequestConfig();
 
-        HttpParams params = method.getParams();
-        assertNotNull( params );
-        assertEquals( maxRedirects, params.getIntParameter( ClientPNames.MAX_REDIRECTS, -1 ) );
+        assertEquals(2, requestConfig.getMaxRedirects());
     }
 
     public void testDefaultHeadersUsedByDefault()

http://git-wip-us.apache.org/repos/asf/maven-wagon/blob/a12972eb/wagon-providers/wagon-http/src/test/java/org/apache/maven/wagon/providers/http/HttpWagonTest.java
----------------------------------------------------------------------
diff --git a/wagon-providers/wagon-http/src/test/java/org/apache/maven/wagon/providers/http/HttpWagonTest.java b/wagon-providers/wagon-http/src/test/java/org/apache/maven/wagon/providers/http/HttpWagonTest.java
old mode 100644
new mode 100755
index e38046c..edc7538
--- a/wagon-providers/wagon-http/src/test/java/org/apache/maven/wagon/providers/http/HttpWagonTest.java
+++ b/wagon-providers/wagon-http/src/test/java/org/apache/maven/wagon/providers/http/HttpWagonTest.java
@@ -19,13 +19,13 @@ package org.apache.maven.wagon.providers.http;
  * under the License.
  */
 
-import org.apache.http.impl.conn.PoolingClientConnectionManager;
+import java.util.Properties;
+
+import org.apache.http.impl.conn.PoolingHttpClientConnectionManager;
 import org.apache.maven.wagon.StreamingWagon;
 import org.apache.maven.wagon.Wagon;
 import org.apache.maven.wagon.http.HttpWagonTestCase;
 
-import java.util.Properties;
-
 /**
  * @author <a href="michal.maczka@dimatics.com">Michal Maczka</a>
  */
@@ -56,7 +56,7 @@ public class HttpWagonTest
         throws Exception
     {
         HttpWagon wagon = (HttpWagon) lookup( Wagon.class, "http" );
-        assertTrue( wagon.getConnectionManager() instanceof PoolingClientConnectionManager );
+        assertTrue( wagon.getConnectionManager() instanceof PoolingHttpClientConnectionManager );
 
     }
 


Mime
View raw message