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