Browse Source

optionally don't follow redirects in <http>

https://bz.apache.org/bugzilla/show_bug.cgi?id=58840
master
Stefan Bodewig 9 years ago
parent
commit
c78ecf75bb
3 changed files with 21 additions and 1 deletions
  1. +3
    -0
      WHATSNEW
  2. +7
    -0
      manual/Tasks/conditions.html
  3. +11
    -1
      src/main/org/apache/tools/ant/taskdefs/condition/Http.java

+ 3
- 0
WHATSNEW View File

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



+ 7
- 0
manual/Tasks/conditions.html View File

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


+ 11
- 1
src/main/org/apache/tools/ant/taskdefs/condition/Http.java View File

@@ -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
@@ -79,6 +79,15 @@ public class Http extends ProjectComponent implements Condition {
: method.toUpperCase(Locale.ENGLISH);
}

/**
* 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);


Loading…
Cancel
Save