Skip to content

Commit

Permalink
Also update the Host: header
Browse files Browse the repository at this point in the history
... we still pass through the original Referer header, maybe we should
remove that
  • Loading branch information
Max Maischein committed Nov 8, 2024
1 parent 26c7c50 commit 29bf44c
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion script/curl.pl
Original file line number Diff line number Diff line change
Expand Up @@ -109,13 +109,16 @@ ( $request )
# what do we do about 301 redirects?!
msg(sprintf "Got %d status for $url", $res->code);

# Build a fresh request from the old one
my $redirect = { $request->%* };
my $target = Mojo::URL->new( $res->headers->header('Location') );
$redirect->{headers}->{Host} = $target->host;
$redirect->{progress} = $progress;
$progress->visual( "$target" );
$progress->total(undef);
$redirect->{url} = $res->headers->header('Location');

return submit_download($redirect);

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

0 comments on commit 29bf44c

Please sign in to comment.