Skip to content

Commit

Permalink
Follow 302 redirects
Browse files Browse the repository at this point in the history
  • Loading branch information
Max Maischein committed Nov 8, 2024
1 parent 78cb600 commit fd6e1fc
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion script/curl.pl
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ ( $request )
my $filename = $request->{target};
msg("$method $url");

my $progress = JobFunnel::ProgressItem->new(
my $progress = $request->{progress} // JobFunnel::ProgressItem->new(
visual => $url,
action => 'dl',
total => undef,
Expand Down Expand Up @@ -108,6 +108,13 @@ ( $request )
} elsif( $res->code =~ /^3\d\d/ ) {
# what do we do about 301 redirects?!
msg(sprintf "Got %d status for $url", $res->code);

my $redirect = { $request->%* };
$redirect->{progress} = $progress;
$redirect->{url} = $res->headers->header('Location');

submit_download($redirect);

} else {
msg(sprintf "HTTP Error %d: %s", $res->code, $res->message);
}
Expand Down

0 comments on commit fd6e1fc

Please sign in to comment.