git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@277761 13f79535-47bb-0310-9956-ffa450edef68master
@@ -357,6 +357,8 @@ Fixed bugs: | |||||
* Get with usetimestamp did not work on Java 1.2. | * Get with usetimestamp did not work on Java 1.2. | ||||
* Get with usetimestamp did not work when local timestamp roughly >= now. | |||||
Changes from Ant 1.6.1 to Ant 1.6.2 | Changes from Ant 1.6.1 to Ant 1.6.2 | ||||
=================================== | =================================== | ||||
@@ -37,11 +37,25 @@ | |||||
</fail> | </fail> | ||||
</target> | </target> | ||||
<target name="testUseTimestamp"> | |||||
<target name="testUseTimestamp" depends="-90s,-timestamp" /> | |||||
<target name="-90s"> | |||||
<property name="off" value="-90" /> | |||||
<property name="unit" value="second" /> | |||||
</target> | |||||
<target name="testUseTomorrow" depends="+1d,-timestamp" /> | |||||
<target name="+1d"> | |||||
<property name="off" value="1" /> | |||||
<property name="unit" value="day" /> | |||||
</target> | |||||
<target name="-timestamp"> | |||||
<property name="pat" value="yyyyMMddHHmm" /> | <property name="pat" value="yyyyMMddHHmm" /> | ||||
<tstamp> | <tstamp> | ||||
<format property="dt" pattern="${pat}" offset="-90" unit="second" /> | |||||
<format property="dt" pattern="${pat}" offset="${off}" unit="${unit}" /> | |||||
</tstamp> | </tstamp> | ||||
<touch file="get.tmp" datetime="${dt}" pattern="${pat}" /> | <touch file="get.tmp" datetime="${dt}" pattern="${pat}" /> | ||||
@@ -160,20 +160,17 @@ public class Get extends Task { | |||||
if (connection instanceof HttpURLConnection) { | if (connection instanceof HttpURLConnection) { | ||||
HttpURLConnection httpConnection | HttpURLConnection httpConnection | ||||
= (HttpURLConnection) connection; | = (HttpURLConnection) connection; | ||||
long lastModified = httpConnection.getLastModified(); | |||||
if (httpConnection.getResponseCode() | if (httpConnection.getResponseCode() | ||||
== HttpURLConnection.HTTP_NOT_MODIFIED | == HttpURLConnection.HTTP_NOT_MODIFIED | ||||
//workaround: doesn't work on 1.2 | |||||
|| (hasTimestamp | |||||
&& JavaEnvUtils.isJavaVersion(JavaEnvUtils.JAVA_1_2) | |||||
&& timestamp > httpConnection.getLastModified())) { | |||||
|| (lastModified != 0 && hasTimestamp | |||||
&& timestamp > lastModified)) { | |||||
//not modified so no file download. just return | //not modified so no file download. just return | ||||
//instead and trace out something so the user | //instead and trace out something so the user | ||||
//doesn't think that the download happened when it | //doesn't think that the download happened when it | ||||
//didn't | //didn't | ||||
log("Not modified - so not downloaded", logLevel); | log("Not modified - so not downloaded", logLevel); | ||||
return false; | return false; | ||||
// also, if timestamp is roughly >= now, HTTP_NOT_MODIFIED is _not_ | |||||
// returned... We may want to remove the 1.2 qualifier above. | |||||
} | } | ||||
// test for 401 result (HTTP only) | // test for 401 result (HTTP only) | ||||
if (httpConnection.getResponseCode() | if (httpConnection.getResponseCode() | ||||
@@ -64,4 +64,8 @@ public class GetTest extends BuildFileTest { | |||||
executeTarget("testUseTimestamp"); | executeTarget("testUseTimestamp"); | ||||
} | } | ||||
public void testUseTomorrow() { | |||||
executeTarget("testUseTomorrow"); | |||||
} | |||||
} | } |