You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by ah...@apache.org on 2006/03/31 01:11:51 UTC

svn commit: r390276 - /maven/maven-1/plugins/trunk/linkcheck/src/main/org/apache/maven/plugin/linkcheck/validation/OnlineHTTPLinkValidator.java

Author: aheritier
Date: Thu Mar 30 15:11:50 2006
New Revision: 390276

URL: http://svn.apache.org/viewcvs?rev=390276&view=rev
Log:
Add a warning for all moves (temporary or not)

Modified:
    maven/maven-1/plugins/trunk/linkcheck/src/main/org/apache/maven/plugin/linkcheck/validation/OnlineHTTPLinkValidator.java

Modified: maven/maven-1/plugins/trunk/linkcheck/src/main/org/apache/maven/plugin/linkcheck/validation/OnlineHTTPLinkValidator.java
URL: http://svn.apache.org/viewcvs/maven/maven-1/plugins/trunk/linkcheck/src/main/org/apache/maven/plugin/linkcheck/validation/OnlineHTTPLinkValidator.java?rev=390276&r1=390275&r2=390276&view=diff
==============================================================================
--- maven/maven-1/plugins/trunk/linkcheck/src/main/org/apache/maven/plugin/linkcheck/validation/OnlineHTTPLinkValidator.java (original)
+++ maven/maven-1/plugins/trunk/linkcheck/src/main/org/apache/maven/plugin/linkcheck/validation/OnlineHTTPLinkValidator.java Thu Mar 30 15:11:50 2006
@@ -138,7 +138,10 @@
             }
             else
             {
-                if ( hm.getStatusCode() == HttpStatus.SC_MOVED_PERMANENTLY )
+                // 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 )
                 {
                     LOG.warn( "Received: [" + hm.getStatusCode() + "] for [" + lvi.getLink() + "] in page ["
                         + lvi.getSource() + "]" );
@@ -264,11 +267,11 @@
                     }
                     HttpMethod oldHm = hm;
                     LOG.info( "[" + link + "] is redirected to [" + newLink + "]" );
-                    hm.releaseConnection();
+                    oldHm.releaseConnection();
                     hm = checkLink( cl, newLink, nbRedirect + 1 );
-                    // Restore the hm to "Moved permanently" if the new location is found to allow us to report it
-                    if ( oldHm.getStatusCode() == HttpStatus.SC_MOVED_PERMANENTLY
-                        && hm.getStatusCode() == HttpStatus.SC_OK )
+                    // 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;
                     }