ant-notifications mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bode...@apache.org
Subject svn commit: r1429209 - in /ant/core/trunk: WHATSNEW src/main/org/apache/tools/ant/taskdefs/Get.java src/tests/antunit/taskdefs/get-test.xml
Date Sat, 05 Jan 2013 06:58:40 GMT
Author: bodewig
Date: Sat Jan  5 06:58:39 2013
New Revision: 1429209

URL: http://svn.apache.org/viewvc?rev=1429209&view=rev
Log:
PR 54374: support status code 307 redirects in <get>

Modified:
    ant/core/trunk/WHATSNEW
    ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/Get.java
    ant/core/trunk/src/tests/antunit/taskdefs/get-test.xml

Modified: ant/core/trunk/WHATSNEW
URL: http://svn.apache.org/viewvc/ant/core/trunk/WHATSNEW?rev=1429209&r1=1429208&r2=1429209&view=diff
==============================================================================
--- ant/core/trunk/WHATSNEW (original)
+++ ant/core/trunk/WHATSNEW Sat Jan  5 06:58:39 2013
@@ -56,6 +56,9 @@ Fixed bugs:
    was empty.
    Bugzilla Report 53626.
 
+ * <get> now supports HTTP redirects using status code 307.
+   Bugzilla Report 54374.
+
 Other changes:
 --------------
 

Modified: ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/Get.java
URL: http://svn.apache.org/viewvc/ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/Get.java?rev=1429209&r1=1429208&r2=1429209&view=diff
==============================================================================
--- ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/Get.java (original)
+++ ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/Get.java Sat Jan  5 06:58:39 2013
@@ -58,6 +58,9 @@ public class Get extends Task {
     private static final int BIG_BUFFER_SIZE = 100 * 1024;
     private static final FileUtils FILE_UTILS = FileUtils.getFileUtils();
     private static final int REDIRECT_LIMIT = 25;
+    // HttpURLConnection doesn't have a constant for this in Java5 and
+    // what it calls HTTP_MOVED_TEMP would better be FOUND
+    private static final int HTTP_MOVED_TEMP = 307;
 
     private static final String HTTP = "http";
     private static final String HTTPS = "https";
@@ -666,7 +669,8 @@ public class Get extends Task {
                 int responseCode = httpConnection.getResponseCode();
                 if (responseCode == HttpURLConnection.HTTP_MOVED_PERM || 
                         responseCode == HttpURLConnection.HTTP_MOVED_TEMP ||
-                        responseCode == HttpURLConnection.HTTP_SEE_OTHER)
+                        responseCode == HttpURLConnection.HTTP_SEE_OTHER ||
+                        responseCode == HTTP_MOVED_TEMP)
                 {
                     String newLocation = httpConnection.getHeaderField("Location");
                     String message = aSource

Modified: ant/core/trunk/src/tests/antunit/taskdefs/get-test.xml
URL: http://svn.apache.org/viewvc/ant/core/trunk/src/tests/antunit/taskdefs/get-test.xml?rev=1429209&r1=1429208&r2=1429209&view=diff
==============================================================================
--- ant/core/trunk/src/tests/antunit/taskdefs/get-test.xml (original)
+++ ant/core/trunk/src/tests/antunit/taskdefs/get-test.xml Sat Jan  5 06:58:39 2013
@@ -64,6 +64,19 @@
         <au:assertLogContains text="temp.txt moved to http" />
     </target>
     
+    <target name="testStatusCode307Redirect">
+      <get  src="${location}/307.txt" dest="${output}/307.txt"/>
+        <au:assertTrue>
+          <resourcecount count="1">
+            <restrict>
+              <file file="${output}/307.txt" />
+              <contains text="307 status code redirect succeeded" />
+            </restrict>
+          </resourcecount>
+        </au:assertTrue>
+        <au:assertLogContains text="307.txt moved to http" />
+    </target>
+    
     <target name="test5LevelsOfRedirect">
       <get  src="${location}/redir5.txt" dest="${output}/redir5.tmp"/>
         <au:assertTrue>



Mime
View raw message