You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@flex.apache.org by ah...@apache.org on 2014/10/21 21:35:44 UTC
git commit: [flex-utilities] [refs/heads/develop] - add sourceforge
hack workaround to get task. It checks for a particular response from
sourceforge and uses a different pattern as the redirect URL
Repository: flex-utilities
Updated Branches:
refs/heads/develop 3ed1b4f7c -> 52759fd93
add sourceforge hack workaround to get task. It checks for a particular response from sourceforge and uses a different pattern as the redirect URL
Project: http://git-wip-us.apache.org/repos/asf/flex-utilities/repo
Commit: http://git-wip-us.apache.org/repos/asf/flex-utilities/commit/52759fd9
Tree: http://git-wip-us.apache.org/repos/asf/flex-utilities/tree/52759fd9
Diff: http://git-wip-us.apache.org/repos/asf/flex-utilities/diff/52759fd9
Branch: refs/heads/develop
Commit: 52759fd93a664676b149b77e57ddbfaa824e579d
Parents: 3ed1b4f
Author: Alex Harui <ah...@apache.org>
Authored: Tue Oct 21 12:35:31 2014 -0700
Committer: Alex Harui <ah...@apache.org>
Committed: Tue Oct 21 12:35:31 2014 -0700
----------------------------------------------------------------------
ant_on_air/src/org/apache/flex/ant/tags/Get.as | 20 ++++++++++++++++++++
1 file changed, 20 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/flex-utilities/blob/52759fd9/ant_on_air/src/org/apache/flex/ant/tags/Get.as
----------------------------------------------------------------------
diff --git a/ant_on_air/src/org/apache/flex/ant/tags/Get.as b/ant_on_air/src/org/apache/flex/ant/tags/Get.as
index 3a006cc..bf0f549 100644
--- a/ant_on_air/src/org/apache/flex/ant/tags/Get.as
+++ b/ant_on_air/src/org/apache/flex/ant/tags/Get.as
@@ -47,6 +47,11 @@ package org.apache.flex.ant.tags
Ant.antTagProcessors["get"] = Get;
}
+ private static const DOWNLOADS_SOURCEFORGE_NET = "http://downloads.sourceforge.net/";
+ private static const SOURCEFORGE_NET = "http://sourceforge.net/";
+ private static const DL_SOURCEFORGE_NET = ".dl.sourceforge.net/";
+ private static const USE_MIRROR = "use_mirror=";
+
public function Get()
{
super();
@@ -94,6 +99,7 @@ package org.apache.flex.ant.tags
var actualSrc:String = src;
var urlRequest:URLRequest = new URLRequest(actualSrc);
urlRequest.followRedirects = false;
+ urlRequest.manageCookies = false;
urlRequest.userAgent = "Java"; // required to get sourceforge redirects to do the right thing
urlLoader = new URLLoader();
urlLoader.load(urlRequest);
@@ -132,10 +138,24 @@ package org.apache.flex.ant.tags
}
if (newlocation)
{
+ var srcIndex:int = src.indexOf(DOWNLOADS_SOURCEFORGE_NET);
+ var sfIndex:int = newlocation.indexOf(SOURCEFORGE_NET);
+ var mirrorIndex:int = newlocation.indexOf(USE_MIRROR);
+ if (srcIndex == 0 && sfIndex == 0 && mirrorIndex != -1 && event.status == 307)
+ {
+ // SourceForge redirects AIR requests differently from Ant requests.
+ // We can't control some of the additional headers that are sent
+ // but that appears to make the difference. Just pick out the
+ // mirror and use it against dl.sourceforge.net
+ var mirror:String = newlocation.substring(mirrorIndex + USE_MIRROR.length);
+ newlocation = "http://" + mirror + DL_SOURCEFORGE_NET;
+ newlocation += src.substring(DOWNLOADS_SOURCEFORGE_NET.length);
+ }
ant.output(ant.formatOutput("get", "Redirected to: " + newlocation));
var urlRequest:URLRequest = new URLRequest(newlocation);
var refHeader:URLRequestHeader = new URLRequestHeader("Referer", src);
urlRequest.requestHeaders.push(refHeader);
+ urlRequest.manageCookies = false;
urlRequest.followRedirects = false;
urlRequest.userAgent = "Java"; // required to get sourceforge redirects to do the right thing
urlLoader = new URLLoader();