You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by el...@apache.org on 2021/01/17 16:06:46 UTC

[maven-doxia-linkcheck] branch http created (now 1f7813a)

This is an automated email from the ASF dual-hosted git repository.

elharo pushed a change to branch http
in repository https://gitbox.apache.org/repos/asf/maven-doxia-linkcheck.git.


      at 1f7813a  update to HttpClient 4.5

This branch includes the following new commits:

     new 1f7813a  update to HttpClient 4.5

The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.



[maven-doxia-linkcheck] 01/01: update to HttpClient 4.5

Posted by el...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

elharo pushed a commit to branch http
in repository https://gitbox.apache.org/repos/asf/maven-doxia-linkcheck.git

commit 1f7813a9328732e1bd0408964d24c6edcd2425ae
Author: Elliotte Rusty Harold <el...@ibiblio.org>
AuthorDate: Sun Jan 17 11:06:13 2021 -0500

    update to HttpClient 4.5
---
 pom.xml                                            |  14 +-
 .../maven/doxia/linkcheck/DefaultLinkCheck.java    |  10 +-
 .../apache/maven/doxia/linkcheck/LinkCheck.java    |   8 +-
 .../validation/OnlineHTTPLinkValidator.java        | 313 +++++++++------------
 src/main/mdo/httpbean.mdo                          |   3 +-
 5 files changed, 148 insertions(+), 200 deletions(-)

diff --git a/pom.xml b/pom.xml
index 021991b..3a05841 100644
--- a/pom.xml
+++ b/pom.xml
@@ -64,15 +64,21 @@ under the License.
   <dependencies>
     <!-- compile dependencies -->
     <dependency>
-      <groupId>commons-httpclient</groupId>
-      <artifactId>commons-httpclient</artifactId>
-      <version>3.1</version>
+      <groupId>org.apache.httpcomponents</groupId>
+      <artifactId>httpclient</artifactId>
+      <version>4.5.13</version>
     </dependency>
     <dependency>
       <groupId>commons-logging</groupId>
       <artifactId>commons-logging</artifactId>
       <version>1.2</version>
     </dependency>
+    <dependency>
+      <groupId>org.apache.httpcomponents</groupId>
+      <artifactId>httpclient</artifactId>
+      <version>4.5.13</version>
+    </dependency>
+    
     <!-- Not included in Httpclient -->
     <dependency>
       <groupId>log4j</groupId>
@@ -98,7 +104,7 @@ under the License.
     <dependency>
       <groupId>junit</groupId>
       <artifactId>junit</artifactId>
-      <version>3.8.2</version>
+      <version>4.13.1</version>
       <scope>test</scope>
     </dependency>
   </dependencies>
diff --git a/src/main/java/org/apache/maven/doxia/linkcheck/DefaultLinkCheck.java b/src/main/java/org/apache/maven/doxia/linkcheck/DefaultLinkCheck.java
index 39a12cd..d9b6713 100644
--- a/src/main/java/org/apache/maven/doxia/linkcheck/DefaultLinkCheck.java
+++ b/src/main/java/org/apache/maven/doxia/linkcheck/DefaultLinkCheck.java
@@ -84,23 +84,19 @@ public final class DefaultLinkCheck
     private String[] excludedPages = null;
 
     /**
-     * Excluded http errors only in on line mode.
-     *
-     * @see {@link HttpStatus} for all defined values.
+     * Excluded http errors only in online mode.
      */
     private int[] excludedHttpStatusErrors = null;
 
     /**
-     * Excluded http warnings only in on line mode.
-     *
-     * @see {@link HttpStatus} for all defined values.
+     * Excluded http warnings only in online mode.
      */
     private int[] excludedHttpStatusWarnings = null;
 
     /** Online mode. */
     private boolean online;
 
-    /** Bean enncapsuling some https parameters */
+    /** Bean enncapsulating some https parameters */
     private HttpBean http;
 
     /** Internal LinkValidatorManager. */
diff --git a/src/main/java/org/apache/maven/doxia/linkcheck/LinkCheck.java b/src/main/java/org/apache/maven/doxia/linkcheck/LinkCheck.java
index af0c4c6..a5ea0f1 100644
--- a/src/main/java/org/apache/maven/doxia/linkcheck/LinkCheck.java
+++ b/src/main/java/org/apache/maven/doxia/linkcheck/LinkCheck.java
@@ -48,16 +48,14 @@ public interface LinkCheck
     void setBaseURL( String url );
 
     /**
-     * Sets the excluded HTTP errors, i.e. <code>404</code>, a int[] with excluded errors.
-     * See {@link org.apache.commons.httpclient.HttpStatus} for all possible values.
+     * Sets the excluded HTTP errors; e.g. <code>404</code>, a int[] with excluded errors.
      *
      * @param excl The excludes to set
      */
     void setExcludedHttpStatusErrors( int[] excl );
 
     /**
-     * Sets the excluded HTTP warnings, i.e. <code>301</code>, a int[] with excluded errors.
-     * See {@link org.apache.commons.httpclient.HttpStatus} for all possible values.
+     * Sets the excluded HTTP warnings, e.g. <code>301</code>, a int[] with excluded errors.
      *
      * @param excl The excludes to set
      */
@@ -66,7 +64,7 @@ public interface LinkCheck
     /**
      * Sets the excluded links, a String[] with excluded locations.
      * Could contains a link, i.e. <code>http:&#47;&#47;maven.apache.org/</code>,
-     * or pattern links i.e. <code>http:&#47;&#47;maven.apache.org&#47;**&#47;*.html</code>
+     * or pattern links. E.g. <code>http:&#47;&#47;maven.apache.org&#47;**&#47;*.html</code>
      *
      * @param excl The excludes to set
      */
diff --git a/src/main/java/org/apache/maven/doxia/linkcheck/validation/OnlineHTTPLinkValidator.java b/src/main/java/org/apache/maven/doxia/linkcheck/validation/OnlineHTTPLinkValidator.java
index b9c4bfe..f25e1b3 100644
--- a/src/main/java/org/apache/maven/doxia/linkcheck/validation/OnlineHTTPLinkValidator.java
+++ b/src/main/java/org/apache/maven/doxia/linkcheck/validation/OnlineHTTPLinkValidator.java
@@ -24,26 +24,31 @@ import java.io.IOException;
 import java.net.URL;
 import java.util.Map;
 
-import org.apache.commons.httpclient.Credentials;
-import org.apache.commons.httpclient.Header;
-import org.apache.commons.httpclient.HostConfiguration;
-import org.apache.commons.httpclient.HttpClient;
-import org.apache.commons.httpclient.HttpException;
-import org.apache.commons.httpclient.HttpMethod;
-import org.apache.commons.httpclient.HttpState;
-import org.apache.commons.httpclient.HttpStatus;
-import org.apache.commons.httpclient.MultiThreadedHttpConnectionManager;
-import org.apache.commons.httpclient.NTCredentials;
-import org.apache.commons.httpclient.StatusLine;
-import org.apache.commons.httpclient.UsernamePasswordCredentials;
-import org.apache.commons.httpclient.auth.AuthScope;
-import org.apache.commons.httpclient.methods.GetMethod;
-import org.apache.commons.httpclient.methods.HeadMethod;
-import org.apache.commons.httpclient.params.HttpClientParams;
-import org.apache.commons.httpclient.params.HttpMethodParams;
+import org.apache.http.Header;
+import org.apache.http.HttpException;
+import org.apache.http.HttpHost;
+import org.apache.http.HttpResponse;
+import org.apache.http.HttpStatus;
+import org.apache.http.StatusLine;
+import org.apache.http.auth.AuthScope;
+import org.apache.http.auth.Credentials;
+import org.apache.http.auth.NTCredentials;
+import org.apache.http.auth.UsernamePasswordCredentials;
+import org.apache.http.client.CredentialsProvider;
+import org.apache.http.client.HttpClient;
+import org.apache.http.client.config.RequestConfig;
+import org.apache.http.client.methods.HttpGet;
+import org.apache.http.client.methods.HttpHead;
 
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
+import org.apache.http.client.methods.HttpUriRequest;
+import org.apache.http.config.SocketConfig;
+import org.apache.http.impl.client.BasicCredentialsProvider;
+import org.apache.http.impl.client.HttpClientBuilder;
+import org.apache.http.impl.client.HttpClients;
+import org.apache.http.impl.conn.PoolingHttpClientConnectionManager;
+import org.apache.http.util.EntityUtils;
 import org.apache.maven.doxia.linkcheck.HttpBean;
 import org.apache.maven.doxia.linkcheck.model.LinkcheckFileResult;
 import org.codehaus.plexus.util.StringUtils;
@@ -64,13 +69,7 @@ public final class OnlineHTTPLinkValidator
     /** The maximum number of redirections for a link. */
     private static final int MAX_NB_REDIRECT = 10;
 
-    /** Use the get method to test pages. */
-    private static final String GET_METHOD = "get";
-
-    /** Use the head method to test pages. */
-    private static final String HEAD_METHOD = "head";
-
-    /** The http bean encapsuling all http parameters supported. */
+    /** The http bean encapsulating all http parameters supported. */
     private HttpBean http;
 
     /** The base URL for links that start with '/'. */
@@ -90,7 +89,7 @@ public final class OnlineHTTPLinkValidator
     /**
      * Constructor: initialize settings.
      *
-     * @param bean The http bean encapsuling all HTTP parameters supported.
+     * @param bean the http bean encapsuling all HTTP parameters supported
      */
     public OnlineHTTPLinkValidator( HttpBean bean )
     {
@@ -99,10 +98,7 @@ public final class OnlineHTTPLinkValidator
             bean = new HttpBean();
         }
 
-        if ( LOG.isDebugEnabled() )
-        {
-            LOG.debug( "Will use method : [" + bean.getMethod() + "]" );
-        }
+        LOG.debug( "Using method : [" + bean.getMethod() + "]" );
 
         this.http = bean;
 
@@ -149,11 +145,6 @@ public final class OnlineHTTPLinkValidator
             }
         }
 
-        // Some web servers don't allow the default user-agent sent by httpClient
-        System.setProperty( HttpMethodParams.USER_AGENT, "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.0)" );
-        this.cl.getParams().setParameter( HttpMethodParams.USER_AGENT,
-                                          "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.0)" );
-
         String link = lvi.getLink();
         String anchor = "";
         int idx = link.indexOf( '#' );
@@ -182,12 +173,12 @@ public final class OnlineHTTPLinkValidator
                 link = getBaseURL() + link;
             }
 
-            HttpMethod hm = null;
+            HttpResponse hm = null;
             try
             {
                 hm = checkLink( link, 0 );
             }
-            catch ( Throwable t )
+            catch ( IOException t )
             {
                 if ( LOG.isDebugEnabled() )
                 {
@@ -201,15 +192,16 @@ public final class OnlineHTTPLinkValidator
             if ( hm == null )
             {
                 return new LinkValidationResult( LinkcheckFileResult.ERROR_LEVEL, false,
-                                                 "Cannot retreive HTTP Status" );
+                                                 "Cannot retrieve HTTP Status" );
             }
 
-            if ( hm.getStatusCode() == HttpStatus.SC_OK )
+            int statusCode = hm.getStatusLine().getStatusCode();
+            if ( statusCode == HttpStatus.SC_OK )
             {
-                // lets check if the anchor is present
+                // check if the anchor is present
                 if ( anchor.length() > 0 )
                 {
-                    String content = hm.getResponseBodyAsString();
+                    String content = EntityUtils.toString( hm.getEntity() );
 
                     if ( !Anchors.matchesAnchor( content, anchor ) )
                     {
@@ -217,46 +209,37 @@ public final class OnlineHTTPLinkValidator
                             "Missing anchor '" + anchor + "'" );
                     }
                 }
-                return new HTTPLinkValidationResult( LinkcheckFileResult.VALID_LEVEL, true, hm.getStatusCode(),
-                                                     hm.getStatusText() );
+                return new HTTPLinkValidationResult( LinkcheckFileResult.VALID_LEVEL, true,
+                        statusCode, hm.getStatusLine().getReasonPhrase() );
             }
 
-            String msg =
-                "Received: [" + hm.getStatusCode() + "] for [" + link + "] in page [" + lvi.getSource() + "]";
-            // If there's a redirection ... add a warning
-            if ( hm.getStatusCode() == HttpStatus.SC_MOVED_PERMANENTLY
-                || hm.getStatusCode() == HttpStatus.SC_MOVED_TEMPORARILY
-                || hm.getStatusCode() == HttpStatus.SC_TEMPORARY_REDIRECT )
+            String msg = "Received: [" + statusCode + "] for [" + link + "] in page ["
+                    + lvi.getSource() + "]";
+            // If there's a redirection, add a warning
+            if ( statusCode == HttpStatus.SC_MOVED_PERMANENTLY
+                || statusCode == HttpStatus.SC_MOVED_TEMPORARILY
+                || statusCode == HttpStatus.SC_TEMPORARY_REDIRECT )
             {
                 LOG.warn( msg );
 
-                return new HTTPLinkValidationResult( LinkcheckFileResult.WARNING_LEVEL, true, hm.getStatusCode(),
-                                                     hm.getStatusText() );
+                return new HTTPLinkValidationResult( LinkcheckFileResult.WARNING_LEVEL, true, statusCode,
+                        hm.getStatusLine().getReasonPhrase() );
             }
 
             LOG.debug( msg );
 
-            return new HTTPLinkValidationResult( LinkcheckFileResult.ERROR_LEVEL, false, hm.getStatusCode(),
-                                                 hm.getStatusText() );
+            return new HTTPLinkValidationResult( LinkcheckFileResult.ERROR_LEVEL, false, statusCode,
+                    hm.getStatusLine().getReasonPhrase() );
         }
-        catch ( Throwable t )
+        catch ( Exception t )
         {
             String msg = "Received: [" + t + "] for [" + link + "] in page [" + lvi.getSource() + "]";
-            if ( LOG.isDebugEnabled() )
-            {
-                LOG.debug( msg, t );
-            }
-            else
-            {
-                LOG.error( msg );
-            }
+            LOG.error( msg, t );
 
             return new LinkValidationResult( LinkcheckFileResult.ERROR_LEVEL, false, t.getMessage() );
         }
         finally
         {
-            System.getProperties().remove( HttpMethodParams.USER_AGENT );
-
             if ( this.http.getHttpClientParameters() != null )
             {
                 for ( Map.Entry<Object, Object> entry : this.http.getHttpClientParameters().entrySet() )
@@ -273,61 +256,62 @@ public final class OnlineHTTPLinkValidator
     /** Initialize the HttpClient. */
     private void initHttpClient()
     {
-        LOG.debug( "A new HttpClient instance is needed ..." );
+        LOG.debug( "Creating a new HttpClient instance." );
+
+        HttpClientBuilder builder = HttpClients.custom();
+
+        // connection manager
+        PoolingHttpClientConnectionManager connectionManager = new PoolingHttpClientConnectionManager();
+        connectionManager.setMaxTotal( 100 );
+        connectionManager.setDefaultMaxPerRoute( 10 );
+        builder.setConnectionManager( connectionManager );
 
-        this.cl = new HttpClient( new MultiThreadedHttpConnectionManager() );
+        RequestConfig.Builder requestConfigBuilder = RequestConfig.custom();
+        // redirects
+        requestConfigBuilder.setRedirectsEnabled( this.http.isFollowRedirects() );
 
-        // Default params
+        // timeouts
+        SocketConfig.Builder socketConfigBuilder = SocketConfig.custom();
         if ( this.http.getTimeout() != 0 )
         {
-            this.cl.getHttpConnectionManager().getParams().setConnectionTimeout( this.http.getTimeout() );
-            this.cl.getHttpConnectionManager().getParams().setSoTimeout( this.http.getTimeout() );
+            requestConfigBuilder.setConnectTimeout( this.http.getTimeout() );
+            requestConfigBuilder.setSocketTimeout( this.http.getTimeout() );
+            socketConfigBuilder.setSoTimeout( this.http.getTimeout() );
         }
-        this.cl.getParams().setBooleanParameter( HttpClientParams.ALLOW_CIRCULAR_REDIRECTS, true );
 
-        HostConfiguration hc = new HostConfiguration();
+        builder.setDefaultRequestConfig( requestConfigBuilder.build() );
+        builder.setDefaultSocketConfig( socketConfigBuilder.build() );
 
-        HttpState state = new HttpState();
-        if ( StringUtils.isNotEmpty( this.http.getProxyHost() ) )
+        // proxy
+        if ( StringUtils.isNotBlank( this.http.getProxyHost() ) )
         {
-            hc.setProxy( this.http.getProxyHost(), this.http.getProxyPort() );
-
-            if ( LOG.isDebugEnabled() )
-            {
-                LOG.debug( "Proxy Host:" + this.http.getProxyHost() );
-                LOG.debug( "Proxy Port:" + this.http.getProxyPort() );
-            }
+            HttpHost proxy = new HttpHost( this.http.getProxyHost(), this.http.getProxyPort() );
+            requestConfigBuilder.setProxy( proxy );
+            LOG.debug( "Proxy Host:" + this.http.getProxyHost() );
+            LOG.debug( "Proxy Port:" + this.http.getProxyPort() );
 
             if ( StringUtils.isNotEmpty( this.http.getProxyUser() ) && this.http.getProxyPassword() != null )
             {
-                if ( LOG.isDebugEnabled() )
-                {
-                    LOG.debug( "Proxy User:" + this.http.getProxyUser() );
-                }
+                LOG.debug( "Proxy User:" + this.http.getProxyUser() );
 
                 Credentials credentials;
                 if ( StringUtils.isNotEmpty( this.http.getProxyNtlmHost() ) )
                 {
-                    credentials =
-                        new NTCredentials( this.http.getProxyUser(), this.http.getProxyPassword(),
-                                           this.http.getProxyNtlmHost(), this.http.getProxyNtlmDomain() );
+                    credentials = new NTCredentials( this.http.getProxyUser(), this.http.getProxyPassword(),
+                            this.http.getProxyNtlmHost(), this.http.getProxyNtlmDomain() );
                 }
                 else
                 {
                     credentials =
                         new UsernamePasswordCredentials( this.http.getProxyUser(), this.http.getProxyPassword() );
                 }
-
-                state.setProxyCredentials( AuthScope.ANY, credentials );
+                CredentialsProvider credentialsProvider = new BasicCredentialsProvider();
+                credentialsProvider.setCredentials( AuthScope.ANY, credentials );
+                builder.setDefaultCredentialsProvider( credentialsProvider );
             }
         }
-        else
-        {
-            LOG.debug( "Not using a proxy" );
-        }
 
-        this.cl.setHostConfiguration( hc );
-        this.cl.setState( state );
+        this.cl = builder.build();
 
         LOG.debug( "New HttpClient instance created." );
     }
@@ -335,32 +319,28 @@ public final class OnlineHTTPLinkValidator
     /**
      * Checks the given link.
      *
-     * @param link the link to check.
-     * @param nbRedirect the number of current redirects.
-     * @return HttpMethod
-     * @throws IOException if something goes wrong.
+     * @param link the link to check
+     * @param nbRedirect the number of current redirects
+     * @throws IOException if something goes wrong
      */
-    private HttpMethod checkLink( String link, int nbRedirect )
-        throws IOException
+    private HttpResponse checkLink( String link, int nbRedirect )
+            throws IOException, HttpException
     {
+
+        // check if we've redirected too many times
         int max = MAX_NB_REDIRECT;
         if ( this.http.getHttpClientParameters() != null
-            && this.http.getHttpClientParameters().get( HttpClientParams.MAX_REDIRECTS ) != null )
+            && this.http.getHttpClientParameters().get( "http.protocol.max-redirects" ) != null )
         {
             try
             {
-                max =
-                    Integer.valueOf(
-                                     this.http.getHttpClientParameters().get( HttpClientParams.MAX_REDIRECTS )
-                                              .toString() ).intValue();
+                max = Integer.parseInt(
+                        this.http.getHttpClientParameters().get( "http.protocol.max-redirects" ).toString() );
             }
             catch ( NumberFormatException e )
             {
-                if ( LOG.isWarnEnabled() )
-                {
-                    LOG.warn( "HttpClient parameter '" + HttpClientParams.MAX_REDIRECTS
+                LOG.warn( "HttpClient parameter '" + "http.protocol.max-redirects"
                         + "' is not a number. Ignoring!" );
-                }
             }
         }
         if ( nbRedirect > max )
@@ -368,103 +348,72 @@ public final class OnlineHTTPLinkValidator
             throw new HttpException( "Maximum number of redirections (" + max + ") exceeded" );
         }
 
-        HttpMethod hm;
-        if ( HEAD_METHOD.equalsIgnoreCase( this.http.getMethod() ) )
+        HttpUriRequest request;
+        if ( "HEAD".equalsIgnoreCase( this.http.getMethod() ) )
         {
-            hm = new HeadMethod( link );
+            request = new HttpHead( link );
         }
-        else if ( GET_METHOD.equalsIgnoreCase( this.http.getMethod() ) )
+        else if ( "GET".equalsIgnoreCase( this.http.getMethod() ) )
         {
-            hm = new GetMethod( link );
+            request = new HttpGet( link );
         }
         else
         {
-            if ( LOG.isErrorEnabled() )
-            {
-                LOG.error( "Unsupported method: " + this.http.getMethod() + ", using 'get'." );
-            }
-            hm = new GetMethod( link );
+            LOG.error( "Unsupported method: " + this.http.getMethod() + ", using 'get'." );
+            request = new HttpGet( link );
         }
 
-        // Default
-        hm.setFollowRedirects( this.http.isFollowRedirects() );
+        HttpResponse response = cl.execute( request );
 
-        try
+        StatusLine statusLine = response.getStatusLine();
+        if ( statusLine == null )
         {
-            URL url = new URL( link );
-
-            cl.getHostConfiguration().setHost( url.getHost(), url.getPort(), url.getProtocol() );
+            LOG.error( "Unknown error validating link : " + link );
+            return null;
+        }
 
-            cl.executeMethod( hm );
+        int statusCode = response.getStatusLine().getStatusCode();
+        if ( statusCode == HttpStatus.SC_MOVED_PERMANENTLY
+                || statusCode == HttpStatus.SC_MOVED_TEMPORARILY
+                || statusCode == HttpStatus.SC_TEMPORARY_REDIRECT )
+        {
+            Header[] locationHeader = response.getHeaders( "location" );
 
-            StatusLine sl = hm.getStatusLine();
-            if ( sl == null )
+            if ( locationHeader.length == 0 )
             {
-                if ( LOG.isErrorEnabled() )
-                {
-                    LOG.error( "Unknown error validating link : " + link );
-                }
-
-                return null;
+                LOG.error( "Site sent redirect, but did not set Location header" );
+                return response;
             }
 
-            if ( hm.getStatusCode() == HttpStatus.SC_MOVED_PERMANENTLY
-                || hm.getStatusCode() == HttpStatus.SC_MOVED_TEMPORARILY
-                || hm.getStatusCode() == HttpStatus.SC_TEMPORARY_REDIRECT )
-            {
-                Header locationHeader = hm.getResponseHeader( "location" );
-
-                if ( locationHeader == null )
-                {
-                    LOG.error( "Site sent redirect, but did not set Location header" );
+            String newLink = locationHeader[0].getValue();
 
-                    return hm;
-                }
-
-                String newLink = locationHeader.getValue();
-
-                // Be careful to absolute/relative links
-                if ( !newLink.startsWith( "http://" ) && !newLink.startsWith( "https://" ) )
+            // Be careful to absolute/relative links
+            if ( !newLink.startsWith( "http://" ) && !newLink.startsWith( "https://" ) )
+            {
+                if ( newLink.startsWith( "/" ) )
                 {
-                    if ( newLink.startsWith( "/" ) )
-                    {
-                        URL oldUrl = new URL( link );
-
-                        newLink =
-                            oldUrl.getProtocol() + "://" + oldUrl.getHost()
-                                + ( oldUrl.getPort() > 0 ? ":" + oldUrl.getPort() : "" ) + newLink;
-                    }
-                    else
-                    {
-                        newLink = link + newLink;
-                    }
+                    URL oldUrl = new URL( link );
+                    newLink = oldUrl.getProtocol() + "://" + oldUrl.getHost()
+                            + ( oldUrl.getPort() > 0 ? ":" + oldUrl.getPort() : "" ) + newLink;
                 }
-
-                HttpMethod oldHm = hm;
-
-                if ( LOG.isDebugEnabled() )
+                else
                 {
-                    LOG.debug( "[" + link + "] is redirected to [" + newLink + "]" );
+                    newLink = link + newLink;
                 }
+            }
 
-                oldHm.releaseConnection();
+            LOG.debug( "[" + link + "] is redirected to [" + newLink + "]" );
 
-                hm = checkLink( newLink, nbRedirect + 1 );
+            HttpResponse oldResponse = response;
+            response = checkLink( newLink, nbRedirect + 1 );
 
-                // Restore the hm to "Moved permanently" | "Moved temporarily" | "Temporary redirect"
-                // if the new location is found to allow us to report it
-                if ( hm.getStatusCode() == HttpStatus.SC_OK && nbRedirect == 0 )
-                {
-                    return oldHm;
-                }
+            // Restore the status to "Moved permanently" | "Moved temporarily" | "Temporary redirect"
+            // if the new location is found to allow us to report it
+            if ( statusCode == HttpStatus.SC_OK && nbRedirect == 0 )
+            {
+                return oldResponse;
             }
-
         }
-        finally
-        {
-            hm.releaseConnection();
-        }
-
-        return hm;
+        return response;
     }
 }
diff --git a/src/main/mdo/httpbean.mdo b/src/main/mdo/httpbean.mdo
index dc9fcb0..934bb5d 100644
--- a/src/main/mdo/httpbean.mdo
+++ b/src/main/mdo/httpbean.mdo
@@ -32,8 +32,7 @@ under the License.
   <classes>
     <class>
       <name>HttpBean</name>
-      <description>Http bean to encapsulate the supported HTTP parameters.
-         @see org.apache.commons.httpclient.HttpMethod</description>
+      <description>Http bean to encapsulate the supported HTTP parameters.</description>
       <version>1.0.0</version>
       <fields>
         <field>