You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@maven.apache.org by br...@apache.org on 2004/05/01 03:46:09 UTC

cvs commit: maven-plugins/linkcheck/src/main/org/apache/maven/linkcheck/validation HTTPLinkValidator.java

brett       2004/04/30 18:46:09

  Modified:    linkcheck/src/main/org/apache/maven/linkcheck/validation
                        HTTPLinkValidator.java
  Log:
  PR: MPLINKCHECK-13
  use HEAD instead of GET
  
  Revision  Changes    Path
  1.11      +14 -14    maven-plugins/linkcheck/src/main/org/apache/maven/linkcheck/validation/HTTPLinkValidator.java
  
  Index: HTTPLinkValidator.java
  ===================================================================
  RCS file: /home/cvs/maven-plugins/linkcheck/src/main/org/apache/maven/linkcheck/validation/HTTPLinkValidator.java,v
  retrieving revision 1.10
  retrieving revision 1.11
  diff -u -r1.10 -r1.11
  --- HTTPLinkValidator.java	2 Mar 2004 15:09:17 -0000	1.10
  +++ HTTPLinkValidator.java	1 May 2004 01:46:09 -0000	1.11
  @@ -23,7 +23,7 @@
   import org.apache.commons.httpclient.HttpState;
   import org.apache.commons.httpclient.StatusLine;
   import org.apache.commons.httpclient.UsernamePasswordCredentials;
  -import org.apache.commons.httpclient.methods.GetMethod;
  +import org.apache.commons.httpclient.methods.HeadMethod;
   import org.apache.commons.logging.Log;
   import org.apache.commons.logging.LogFactory;
   
  @@ -96,34 +96,34 @@
               cl.setState(state);
               
               // execute the GET
  -            GetMethod gm = checkLink(cl, link);
  -            StatusLine sl = gm.getStatusLine();
  +            HeadMethod hm = checkLink(cl, link);
  +            StatusLine sl = hm.getStatusLine();
               
               if (sl == null) {
                   LOG.info("Unknown error validating link : " + link);
                   return LVR_VALID;
               }
               
  -            if (gm.getStatusCode() == 302)
  +            if (hm.getStatusCode() == 302)
               {
  -                Header locationHeader = gm.getResponseHeader("Location");
  +                Header locationHeader = hm.getResponseHeader("Location");
                   if (locationHeader == null)  {
                       LOG.info("Site sent redirect, but did not set Location header");
                   } else  {
                       String newLink = locationHeader.getValue();
                       LOG.debug("Following 1 redirect to " + newLink);
  -                    gm = checkLink(cl, newLink);
  +                    hm = checkLink(cl, newLink);
                   }
               }
   
               //FIXME: This constant is defined somewhere, but I can't remember where...
  -            if (gm.getStatusCode() == 200)
  +            if (hm.getStatusCode() == 200)
               {
                   return LVR_VALID;
               }
               else
               {
  -                String msg = "Received: [" + gm.getStatusCode() + "] for " + link;
  +                String msg = "Received: [" + hm.getStatusCode() + "] for " + link;
                   LOG.info(msg);
                   System.out.println(msg);
                   return LVR_INVALID;
  @@ -139,21 +139,21 @@
   
       }
   
  -    private GetMethod checkLink(HttpClient cl, String link)
  +    private HeadMethod checkLink(HttpClient cl, String link)
       {   
  -        GetMethod gm = new GetMethod(link);
  +        HeadMethod hm = new HeadMethod(link);
           try
           {
               LOG.info("Checking link " + link);
  -            gm.setFollowRedirects(true);
  -            cl.executeMethod(gm);
  +            hm.setFollowRedirects(true);
  +            cl.executeMethod(hm);
               LOG.debug("Checked link " + link);
           }
           catch (Exception e)
           {
               LOG.warn("Error validating " + link, e);
           }
  -        return gm;
  +        return hm;
       }
   
       /**
  
  
  

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