From 29bf44ca865b10a1098160668ff99caf8ffaf960 Mon Sep 17 00:00:00 2001 From: Max Maischein Date: Fri, 8 Nov 2024 17:29:55 +0100 Subject: [PATCH] Also update the Host: header ... we still pass through the original Referer header, maybe we should remove that --- script/curl.pl | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/script/curl.pl b/script/curl.pl index 19ce389..837f8ee 100644 --- a/script/curl.pl +++ b/script/curl.pl @@ -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); }