Author: bodewig Date: Wed Aug 26 10:26:35 2009 New Revision: 807953 URL: http://svn.apache.org/viewvc?rev=807953&view=rev Log: Add httpusecaches attribute to <get>. PR 41891
Modified: ant/core/trunk/WHATSNEW ant/core/trunk/docs/manual/CoreTasks/get.html ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/Get.java Modified: ant/core/trunk/WHATSNEW URL: http://svn.apache.org/viewvc/ant/core/trunk/WHATSNEW?rev=807953&r1=807952&r2=807953&view=diff ============================================================================== --- ant/core/trunk/WHATSNEW (original) +++ ant/core/trunk/WHATSNEW Wed Aug 26 10:26:35 2009 @@ -915,6 +915,10 @@ channels. Bugzilla Report 30094. + * <get> 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 ============================================= Modified: ant/core/trunk/docs/manual/CoreTasks/get.html URL: http://svn.apache.org/viewvc/ant/core/trunk/docs/manual/CoreTasks/get.html?rev=807953&r1=807952&r2=807953&view=diff ============================================================================== --- ant/core/trunk/docs/manual/CoreTasks/get.html (original) +++ ant/core/trunk/docs/manual/CoreTasks/get.html Wed Aug 26 10:26:35 2009 @@ -115,6 +115,15 @@ <em>since Ant 1.8.0</em></td> <td align="center" valign="top">No; default "false"</td> </tr> + <tr> + <td valign="top">httpusecaches</td> + <td valign="top">HTTP only - if true, allow caching at the + HttpUrlConnection level. if false, turn caching off.<br/> + <b>Note</b> this is only a hint to the underlying UrlConnection + class, implementations and proxies are free to ignore the + setting.</td> + <td align="center" valign="top">No; default "true"</td> + </tr> </table> <h3>Examples</h3> <pre> <get src="http://ant.apache.org/" dest="help/index.html"/></pre> Modified: ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/Get.java URL: http://svn.apache.org/viewvc/ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/Get.java?rev=807953&r1=807952&r2=807953&view=diff ============================================================================== --- ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/Get.java (original) +++ ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/Get.java Wed Aug 26 10:26:35 2009 @@ -67,6 +67,7 @@ private long maxTime = 0; private int numberRetries = NUMBER_RETRIES; private boolean skipExisting = false; + private boolean httpUseCaches = true; // on by default /** * Does the work. @@ -304,6 +305,20 @@ } /** + * HTTP connections only - control caching on the + * HttpUrlConnection: httpConnection.setUseCaches(); if false, do + * not allow caching on the HttpUrlConnection. + * + * <p>Defaults to true (allow caching, which is also the + * HttpUrlConnection default value.</p> + * + * @since Ant 1.8.0 + */ + public void setHttpUseCaches(boolean httpUseCache) { + this.httpUseCaches = httpUseCache; + } + + /** * Interface implemented for reporting * progess of downloading. */ @@ -507,6 +522,8 @@ 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 @@ // 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 ||