Browse Source

Add httpusecaches attribute to <get>. PR 41891

git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@807953 13f79535-47bb-0310-9956-ffa450edef68
master
Stefan Bodewig 16 years ago
parent
commit
10e250f3b8
3 changed files with 30 additions and 2 deletions
  1. +4
    -0
      WHATSNEW
  2. +9
    -0
      docs/manual/CoreTasks/get.html
  3. +17
    -2
      src/main/org/apache/tools/ant/taskdefs/Get.java

+ 4
- 0
WHATSNEW View File

@@ -915,6 +915,10 @@ Other changes:
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
=============================================



+ 9
- 0
docs/manual/CoreTasks/get.html View File

@@ -115,6 +115,15 @@ plain text' authentication is used. This is only secure over an HTTPS link.
<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> &lt;get src=&quot;http://ant.apache.org/&quot; dest=&quot;help/index.html&quot;/&gt;</pre>


+ 17
- 2
src/main/org/apache/tools/ant/taskdefs/Get.java View File

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


Loading…
Cancel
Save