only enable transparent gzip encoding when explicitly specified fixes bugzilla issue 57048
Project: http://git-wip-us.apache.org/repos/asf/ant/repo Commit: http://git-wip-us.apache.org/repos/asf/ant/commit/faedd2bc Tree: http://git-wip-us.apache.org/repos/asf/ant/tree/faedd2bc Diff: http://git-wip-us.apache.org/repos/asf/ant/diff/faedd2bc Branch: refs/heads/master Commit: faedd2bc5b9fdcaa0650966bc7fef43c5c59cf9a Parents: 090b558 Author: Stefan Bodewig <[email protected]> Authored: Sun Nov 16 12:22:52 2014 +0100 Committer: Stefan Bodewig <[email protected]> Committed: Sun Nov 16 12:22:52 2014 +0100 ---------------------------------------------------------------------- WHATSNEW | 8 ++++++++ manual/Tasks/get.html | 9 +++++++++ src/main/org/apache/tools/ant/taskdefs/Get.java | 21 ++++++++++++++++++-- 3 files changed, 36 insertions(+), 2 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/ant/blob/faedd2bc/WHATSNEW ---------------------------------------------------------------------- diff --git a/WHATSNEW b/WHATSNEW index 43fb6a5..8f8d635 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 <get>'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 <get> 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: ----------- http://git-wip-us.apache.org/repos/asf/ant/blob/faedd2bc/manual/Tasks/get.html ---------------------------------------------------------------------- diff --git a/manual/Tasks/get.html b/manual/Tasks/get.html index c4b7ef6..04bc0e4 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. <em>since Ant 1.9.3</em></td> <td align="center" valign="top">No</td> </tr> + <tr> + <td valign="top">tryGzipEncoding</td> + <td valign="top">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.<br/> + Setting this to true also means Ant will uncompress + <code>.tar.gz</code> and similar files automatically.<br/> + <em>since Ant 1.9.5</em></td> + <td align="center" valign="top">No; default "false"</td> </table> <h3>Parameters specified as nested elements</h3> <h4>any resource collection</h4> http://git-wip-us.apache.org/repos/asf/ant/blob/faedd2bc/src/main/org/apache/tools/ant/taskdefs/Get.java ---------------------------------------------------------------------- diff --git a/src/main/org/apache/tools/ant/taskdefs/Get.java b/src/main/org/apache/tools/ant/taskdefs/Get.java index d3af8e1..c636ab5 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, @@ -460,6 +461,19 @@ public class Get extends Task { } /** + * Whether to transparently try to reduce bandwidth by telling the + * server ant would support gzip encoding. + * + * <p>Setting this to true also means Ant will uncompress + * <code>.tar.gz</code> and similar files automatically.</p> + * + * @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. * @exception BuildException if more than one mapper is defined. @@ -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); }
