diff --git a/WHATSNEW b/WHATSNEW index 8e5452712..28db72a99 100644 --- a/WHATSNEW +++ b/WHATSNEW @@ -915,6 +915,10 @@ Other changes: channels. Bugzilla Report 30094. + * has a new attribute that can be used to disable caching on + HTTP connections at the HttpUrlConnection level. + Bugzilla Report 41891. + Changes from Ant 1.7.0 TO Ant 1.7.1 ============================================= diff --git a/docs/manual/CoreTasks/get.html b/docs/manual/CoreTasks/get.html index bc89e225b..4e602aeda 100644 --- a/docs/manual/CoreTasks/get.html +++ b/docs/manual/CoreTasks/get.html @@ -115,6 +115,15 @@ plain text' authentication is used. This is only secure over an HTTPS link. since Ant 1.8.0 No; default "false" + + httpusecaches + HTTP only - if true, allow caching at the + HttpUrlConnection level. if false, turn caching off.
+ Note this is only a hint to the underlying UrlConnection + class, implementations and proxies are free to ignore the + setting. + No; default "true" +

Examples

  <get src="http://ant.apache.org/" dest="help/index.html"/>
diff --git a/src/main/org/apache/tools/ant/taskdefs/Get.java b/src/main/org/apache/tools/ant/taskdefs/Get.java index f64a1272b..ca9550a6b 100644 --- a/src/main/org/apache/tools/ant/taskdefs/Get.java +++ b/src/main/org/apache/tools/ant/taskdefs/Get.java @@ -67,6 +67,7 @@ public class Get extends Task { private long maxTime = 0; private int numberRetries = NUMBER_RETRIES; private boolean skipExisting = false; + private boolean httpUseCaches = true; // on by default /** * Does the work. @@ -303,6 +304,20 @@ public class Get extends Task { this.skipExisting = s; } + /** + * HTTP connections only - control caching on the + * HttpUrlConnection: httpConnection.setUseCaches(); if false, do + * not allow caching on the HttpUrlConnection. + * + *

Defaults to true (allow caching, which is also the + * HttpUrlConnection default value.

+ * + * @since Ant 1.8.0 + */ + public void setHttpUseCaches(boolean httpUseCache) { + this.httpUseCaches = httpUseCache; + } + /** * Interface implemented for reporting * progess of downloading. @@ -507,6 +522,8 @@ public class Get extends Task { if (connection instanceof HttpURLConnection) { ((HttpURLConnection) connection) .setInstanceFollowRedirects(false); + ((HttpURLConnection) connection) + .setUseCaches(httpUseCaches); } // connect to the remote site (may take some time) connection.connect(); @@ -514,8 +531,6 @@ public class Get extends Task { // First check on a 301 / 302 (moved) response (HTTP only) if (connection instanceof HttpURLConnection) { HttpURLConnection httpConnection = (HttpURLConnection) connection; - // httpConnection.setInstanceFollowRedirects(false); - // httpConnection.setUseCaches(false); int responseCode = httpConnection.getResponseCode(); if (responseCode == HttpURLConnection.HTTP_MOVED_PERM || responseCode == HttpURLConnection.HTTP_MOVED_TEMP ||