Commits

Anonymous committed 2a6e7ae

PR 54374: support status code 307 redirects in <get>

git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@142920913f79535-47bb-0310-9956-ffa450edef68

Comments (0)

Files changed (3)

    was empty.
    Bugzilla Report 53626.
 
+ * <get> now supports HTTP redirects using status code 307.
+   Bugzilla Report 54374.
+
 Other changes:
 --------------
 

src/main/org/apache/tools/ant/taskdefs/Get.java

     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";
                 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

src/tests/antunit/taskdefs/get-test.xml

         <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>