diff --git a/WHATSNEW b/WHATSNEW index 43fb6a5b7..8f8d635e7 100644 --- a/WHATSNEW +++ b/WHATSNEW @@ -13,6 +13,14 @@ Changes that could break older environments: on Ant silently ignoring all but the first character. Bugzilla Report 56584 + * The changes that added 's support for gzip encoding + automatically uncompressed content that would not have been touched + before - like when downloading .tar.gz files. A new flag has been + added to control the behavior and its default will make work + as it did in 1.9.3. I.e. if you want it to work like 1.9.4 + you have to explicitly set tryGzipEncoding to true. + Bugzilla Report 57048 + Fixed bugs: ----------- diff --git a/manual/Tasks/get.html b/manual/Tasks/get.html index c4b7ef6fd..04bc0e4d5 100644 --- a/manual/Tasks/get.html +++ b/manual/Tasks/get.html @@ -134,6 +134,15 @@ plain text' authentication is used. This is only secure over an HTTPS link. since Ant 1.9.3 No + + tryGzipEncoding + When set to true Ant will tell the server it is + willing to accept gzip encoding to reduce the amount of data to + transfer and uncompress the content transparently.
+ Setting this to true also means Ant will uncompress + .tar.gz and similar files automatically.
+ since Ant 1.9.5 + No; default "false"

Parameters specified as nested elements

any resource collection

diff --git a/src/main/org/apache/tools/ant/taskdefs/Get.java b/src/main/org/apache/tools/ant/taskdefs/Get.java index d3af8e166..c636ab54c 100644 --- a/src/main/org/apache/tools/ant/taskdefs/Get.java +++ b/src/main/org/apache/tools/ant/taskdefs/Get.java @@ -83,6 +83,7 @@ public class Get extends Task { private int numberRetries = NUMBER_RETRIES; private boolean skipExisting = false; private boolean httpUseCaches = true; // on by default + private boolean tryGzipEncoding = false; private Mapper mapperElement = null; private String userAgent = System.getProperty(MagicNames.HTTP_AGENT_PROPERTY, @@ -459,6 +460,19 @@ public class Get extends Task { this.httpUseCaches = httpUseCache; } + /** + * Whether to transparently try to reduce bandwidth by telling the + * server ant would support gzip encoding. + * + *

Setting this to true also means Ant will uncompress + * .tar.gz and similar files automatically.

+ * + * @since Ant 1.9.5 + */ + public void setTryGzipEncoding(boolean b) { + tryGzipEncoding = b; + } + /** * Define the mapper to map source to destination files. * @return a mapper to be configured. @@ -699,7 +713,9 @@ public class Get extends Task { + encoding); } - connection.setRequestProperty("Accept-Encoding", GZIP_CONTENT_ENCODING); + if (tryGzipEncoding) { + connection.setRequestProperty("Accept-Encoding", GZIP_CONTENT_ENCODING); + } if (connection instanceof HttpURLConnection) { ((HttpURLConnection) connection) @@ -791,7 +807,8 @@ public class Get extends Task { getLocation()); } - if (GZIP_CONTENT_ENCODING.equals(connection.getContentEncoding())) { + if (tryGzipEncoding + && GZIP_CONTENT_ENCODING.equals(connection.getContentEncoding())) { is = new GZIPInputStream(is); }