hi everyone, i have another approach on this one: 1. check the content type of the download, call a special handler if it is text/html (will also solve #303958) 2. this handler should check the host part of the download url and switch to a site-specific handler 3. the sf handler would then parse the html file, extract the mirrors and retry from one of them
the attached script does this in a ver hackish and dirty way, if you are interested in this solution tell me and i will clean it up cu robert -- Robert Lemmen http://www.semistable.com
--- /usr/bin/uscan 2005-03-24 15:33:37.000000000 +0100
+++ uscan 2005-07-07 16:50:30.000000000 +0200
@@ -906,7 +906,46 @@
warn "$progname warning: In directory $pkg_dir, downloading\n
$upstream_url failed: " . $response->status_line . "\n";
return 1;
}
- }
+ # check if we got a redirection page instead like sf.net does
+ if ($response->header('Content-Type') =~ /^text\/html/) {
+ # seems we got a redirection page, check which host we got this from
+ if (($upstream_url =~ /^http:\/\/prdownloads.sourceforge.net/) ||
+ ($upstream_url =~ /^http:\/\/prdownloads.sf.net/)) {
+ # this is sourceforge, handle it accordingly
+ # read the downloaded file
+ my $dfile;
+ open($dfile, "../$newfile_base") or die "could not open file:
$!";
+ my @refs;
+ while (<$dfile>) {
+ my $string = $_;
+ my @lrefs = $string =~ /<A
HREF=[^?>]*\?use_mirror=([^>]*)>/g;
+ push @refs, @lrefs;
+ }
+ close($dfile);
+ # randomly select one of the mirrors
+ if (@refs) {
+ my $mirror = @refs[rand($#refs+1)];
+ $upstream_url =~
s/http:\/\/[^\/]*/http:\/\/$mirror.dl.sourceforge.net/;
+ print STDERR "$progname debug: requesting URL
$upstream_url\n" if $debug;
+ $request = HTTP::Request->new('GET', $upstream_url);
+ $response = $user_agent->request($request,
"../$newfile_base");
+ if (! $response->is_success) {
+ warn "$progname warning: In directory $pkg_dir,
downloading\n $upstream_url failed: " . $response->status_line . "\n";
+ return 1;
+ }
+ }
+ else {
+ warn "redirection page contained no suitable links to
follow\n";
+ return 1;
+ }
+ }
+ # this is the place were you can insert additional host-specific
handlers
+ else {
+ warn "Content-type did not match, download most probably
broken!\n";
+ return 1;
+ }
+ }
+ }
else {
# FTP site
if (exists $options{'pasv'}) {
signature.asc
Description: Digital signature

