ant-notifications mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bugzi...@apache.org
Subject DO NOT REPLY [Bug 47433] New: Issue with "get" task to download a redirected/moved URL (301/302)
Date Fri, 26 Jun 2009 01:11:41 GMT
https://issues.apache.org/bugzilla/show_bug.cgi?id=47433

           Summary: Issue with "get" task to download a redirected/moved
                    URL (301/302)
           Product: Ant
           Version: 1.7.1
          Platform: All
        OS/Version: Mac OS X 10.4
            Status: NEW
          Severity: major
          Priority: P2
         Component: Core tasks
        AssignedTo: notifications@ant.apache.org
        ReportedBy: jagadesh.munta@sun.com


Email thread sent to the dev@ant.apache.org alias.
Jagadesh Babu Munta wrote:
> Changes again as highlighted (missed couple of lines in earlier email):-
>  
>           int responseCode = httpConnection.getResponseCode();
>             log("Response Code="+responseCode, logLevel);
>             // test for 401 result (HTTP only)
>             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();
>             }
>
>         }
>
>
> Jagadesh Babu Munta wrote:
>> 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

-- 
Configure bugmail: https://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.

Mime
View raw message