You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@ant.apache.org by bo...@apache.org on 2016/02/07 16:02:57 UTC

ant git commit: optionally don't follow redirects in

Repository: ant
Updated Branches:
  refs/heads/master d713b1785 -> c78ecf75b


optionally don't follow redirects in <http>

https://bz.apache.org/bugzilla/show_bug.cgi?id=58840


Project: http://git-wip-us.apache.org/repos/asf/ant/repo
Commit: http://git-wip-us.apache.org/repos/asf/ant/commit/c78ecf75
Tree: http://git-wip-us.apache.org/repos/asf/ant/tree/c78ecf75
Diff: http://git-wip-us.apache.org/repos/asf/ant/diff/c78ecf75

Branch: refs/heads/master
Commit: c78ecf75bbe9219626ebd80c34d9593d3c4b326d
Parents: d713b17
Author: Stefan Bodewig <bo...@apache.org>
Authored: Sun Feb 7 16:02:11 2016 +0100
Committer: Stefan Bodewig <bo...@apache.org>
Committed: Sun Feb 7 16:02:11 2016 +0100

----------------------------------------------------------------------
 WHATSNEW                                                |  3 +++
 manual/Tasks/conditions.html                            |  7 +++++++
 .../org/apache/tools/ant/taskdefs/condition/Http.java   | 12 +++++++++++-
 3 files changed, 21 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ant/blob/c78ecf75/WHATSNEW
----------------------------------------------------------------------
diff --git a/WHATSNEW b/WHATSNEW
index b74181c..9305bc1 100644
--- a/WHATSNEW
+++ b/WHATSNEW
@@ -48,6 +48,9 @@ Other changes:
    addition to filesets.
    Bugzilla Report 50769
 
+ * The <http> condition has a new optional attribute followRedirects.
+   Bugzilla Report 58840
+
 Changes from Ant 1.9.5 TO Ant 1.9.6
 ===================================
 

http://git-wip-us.apache.org/repos/asf/ant/blob/c78ecf75/manual/Tasks/conditions.html
----------------------------------------------------------------------
diff --git a/manual/Tasks/conditions.html b/manual/Tasks/conditions.html
index 814072e..08d0bcc 100644
--- a/manual/Tasks/conditions.html
+++ b/manual/Tasks/conditions.html
@@ -229,6 +229,13 @@ of 400 or greater are viewed as invalid.</p>
       <em>since Ant 1.8.0</em></td>
     <td align="center">No</td>
   </tr>
+  <tr>
+    <td valign="top">followRedirects</td>
+    <td valign="top">Whether redirects should be followed. The default
+      is <code>true</code><br/>
+      <em>since Ant 1.9.7</em></td>
+    <td align="center">No</td>
+  </tr>
 </table>
 
 <h4><a name="socket">socket</a></h4>

http://git-wip-us.apache.org/repos/asf/ant/blob/c78ecf75/src/main/org/apache/tools/ant/taskdefs/condition/Http.java
----------------------------------------------------------------------
diff --git a/src/main/org/apache/tools/ant/taskdefs/condition/Http.java b/src/main/org/apache/tools/ant/taskdefs/condition/Http.java
index 1dc9420..4c04278 100644
--- a/src/main/org/apache/tools/ant/taskdefs/condition/Http.java
+++ b/src/main/org/apache/tools/ant/taskdefs/condition/Http.java
@@ -41,7 +41,7 @@ public class Http extends ProjectComponent implements Condition {
 
     private String spec = null;
     private String requestMethod = DEFAULT_REQUEST_METHOD;
-
+    private boolean followRedirects = true;
 
     /**
      * Set the url attribute
@@ -80,6 +80,15 @@ public class Http extends ProjectComponent implements Condition {
     }
 
     /**
+     * Whether redirects sent by the server should be followed,
+     * defaults to true.
+     * @since Ant 1.9.7
+     */
+    public void setFollowRedirects(boolean f) {
+        followRedirects = f;
+    }
+
+    /**
      * @return true if the HTTP request succeeds
      * @exception BuildException if an error occurs
      */
@@ -95,6 +104,7 @@ public class Http extends ProjectComponent implements Condition {
                 if (conn instanceof HttpURLConnection) {
                     HttpURLConnection http = (HttpURLConnection) conn;
                     http.setRequestMethod(requestMethod);
+                    http.setInstanceFollowRedirects(followRedirects);
                     int code = http.getResponseCode();
                     log("Result code for " + spec + " was " + code,
                         Project.MSG_VERBOSE);