Hi,

I am trying use ANT task "get" to download a redirectored or moved URL "http://hudson-ci.org/latest/hudson.war"
But it doesn't work. It simply get the moved HTML page than the actual redirected URL. Verified with 1.7.1/1.6.5 versions.

I wonder if any workaround?

In fact, I looked at the Get.java taskdef source code and found that code is not taking care of 301/302 HTTP response code.

I have added a simple code (highlighted) in Get.java  and worked fine.

Can some one help me getting the fix into the ant code (or) fixed already (or) if any workaround in the latest (1.7.1) or 1.6.5 ANT bits?
(I joined Today only to this list. Sorry if any one has already discussed the issue.

            if (responseCode == HttpURLConnection.HTTP_UNAUTHORIZED)  {
                String message = "HTTP Authorization failure";
                if (ignoreErrors) {
                    log(message, logLevel);
                    return false;
                } else {
                    throw new BuildException(message);
                }
            } else if ((responseCode == HttpURLConnection.HTTP_MOVED_PERM) ||
                    (responseCode == HttpURLConnection.HTTP_MOVED_TEMP)) {
                String newLocation = httpConnection.getHeaderField("Location");
                String message = "HTTP URL Moved to "+newLocation;
                log(message, logLevel);
                setSrc(new URL(newLocation));
                execute();
            }


        }




Snapshot (problematic):-
------------


     [get] Getting: http://hudson-ci.org/latest/hudson.war
      [get] To: /Users/munta/runtests/v3/appserver-sqe/build/pe/i386_dhcp-usca14-133-126.SFBay.Sun.COM_Darwin/hudson/archive/hudson.war
      [get] ..
      [get] last modified = Wed Dec 31 16:00:00 PST 1969 - using current time instead

BUILD SUCCESSFUL
Total time: 2 seconds
[dhcp-usca14-133-126:v3/appserver-sqe/hudson] munta% cat /Users/munta/runtests/v3/appserver-sqe/build/pe/i386_dhcp-usca14-133-126.SFBay.Sun.COM_Darwin/hudson/archive/hudson.war
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
<HTML><HEAD>
<TITLE>302 Found</TITLE>
</HEAD><BODY>
<H1>Found</H1>
The document has moved <A HREF="https://hudson.dev.java.net/files/documents/2402/137470/hudson.war">here</A>.<P>

<HR>
<ADDRESS>Apache/1.3.33 Server at hudson-ci.org Port 80</ADDRESS>
</BODY></HTML>
[dhcp-usca14-133-126:v3/appserver-sqe/hudson] munta%

---


Snapshot (worked fine with above code change)
---------

      [get] Getting: http://hudson-ci.org/latest/hudson.war
      [get] To: /Users/munta/runtests/v3/appserver-sqe/build/pe/i386_dhcp-usca14-133-126.SFBay.Sun.COM_Darwin/hudson/archive/hudson.war
      [get] Response Code=302
      [get] HTTP URL Moved to https://hudson.dev.java.net/files/documents/2402/137470/hudson.war
      [get] Getting: https://hudson.dev.java.net/files/documents/2402/137470/hudson.war
      [get] To: /Users/munta/runtests/v3/appserver-sqe/build/pe/i386_dhcp-usca14-133-126.SFBay.Sun.COM_Darwin/hudson/archive/hudson.war
      [get] Response Code=200
      [get] ....................................................
      [get] ....................................................
      [get] ....................................................
      [get] ....................................................
      [get] ....................................................
      [get] ....................................................
      [get] ....................................................
      [get] ....................................................
      [get] ....................................................
      [get] ....................................................
      [get] ....................................................
      [get] ....................................................
      [get] ....................................................
      [get] ....................................................
      [get] ....................................................
      [get] ....................................................
      [get] ....................................................
      [get] ....................................................
      [get] ....................................................
      [get] ....................................................
      [get] ....................................................
      [get] ....................................................
      [get] ....................................................
      [get] ....................................................
      [get] ....................................................
      [get] ....................................................
      [get] ....................................................
      [get] ....................................................
      [get] ....................................................
      [get] ....................................................
      [get] ....................................................
      [get] .............................
      [get] last modified = Tue Jun 23 13:57:19 PDT 2009
      [get] ..
      [get] last modified = Wed Dec 31 16:00:00 PST 1969 - using current time instead

BUILD SUCCESSFUL
Total time: 39 seconds


Thanks for your time and help.
-- Jagadesh