From: Jacek Caban Subject: [TOOLS] winegecko.php: Make use of autoselect mirror SourceForge feature. Message-Id: <54F04ADD.2000604@codeweavers.com> Date: Fri, 27 Feb 2015 11:45:49 +0100 This leaves the job of redirecting to mirror to SourceForge, which may do much better job at this than we do. Our current solution is to redirect to random mirror known to have Gecko. In our current code, connection time is bad (it may even feel like it hangs), because we need an additional request from server script to a mirror to ensure that the resource is present there. Also, choosing random mirror often causes pretty bad transfers. The solution from this patch improves this a lot, according to my experiments. The risky part of this patch is that we depend much more on SourceForge. However, since this is server side thing, we may adjust it and/or fallback to the old solution whenever we need, so at least we don't risk permanent breakage if something changes on SourceForge side. Also, I intentionally do this as a minimal change to the script. Once it proves to be working well, we may extend it to be used for Mono and do some clean ups. Additional advantage of this solution is that we will no longer need to update the script for each new release. --- winegecko.php | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/winegecko.php b/winegecko.php index fdc1b96..e44b9e3 100644 --- a/winegecko.php +++ b/winegecko.php @@ -48,6 +48,16 @@ default: // Name of the file $sFileName = sprintf('%s/%s/wine_gecko-%s.%s', $sFolder, $sVersion, $sFileSuffix, $sExt); +// SourceForge can do better job at redirecting to the mirror than us. However, +// it redirects to HTML page by default for web browser user agents. New enough +// Wine set user agent to 'Wine Addon Downloader', so redirect them directly +// to SourceForge. For older Wine and other user agents, fallback to random +// known mirror. +if(strcmp($_SERVER['HTTP_USER_AGENT'], 'Wine Addon Downloader') === 0) { + header("Location: http://sourceforge.net/projects/wine/files/".$sFileName); + exit; +} + // Size array $aFileSizes = array( '0.0.1'=>5219822,