in reply to Re^2: url issues using HTTP::Tiny
in thread url issues using HTTP::Tiny
If it could happen to CGI, it will probably happen to HTTP::Tiny 🔋🗑
UNLESS someone rescues HTTP::Tiny to evolve some sort of fallback functionality along the lines of HTTP::Any like this silly core one-liner, when fed an https url on an https-less perl, will fail and fallback on a random selection of wget or curl (or, like, all known https clients on every operating system?):
perl -MIPC::Cmd=can_run,run -MHTTP::Tiny -le'@c=({wget=>"wget -O-"},{c +url=>"curl"});$u=shift;$r=HTTP::Tiny->new->get($u);if($r->{status}==5 +99){($a,$b)=%{$c[rand@c]};if(my $cmd=can_run($a)){if(scalar run(comma +nd=>"$b $u",buffer=>\my $data)){print"$data\n$cmd"}}}else{print"$r->{ +content}\ntiny"}' "https://www.perlmonks.org"
Let's fix it!perl -MIPC::Cmd=can_run,run -MHTTP::Tiny -le' @c=({wget=>"wget -O-"},{curl=>"curl"}); $u=shift; $r=HTTP::Tiny->new->get($u); if($r->{status}==599){ ($a,$b)=%{$c[rand@c]}; if(my $cmd=can_run($a)){ if(scalar run(command=>"$b $u",buffer=>\my $data){ print"$data\n$cmd" } } } else{print"$r->{content}\ntiny"}' "https://www.perlmonks.org"
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^4: url issues using HTTP::Tiny
by Corion (Patriarch) on Sep 19, 2019 at 07:35 UTC | |
by hippo (Archbishop) on Sep 19, 2019 at 09:08 UTC | |
by marto (Cardinal) on Sep 19, 2019 at 09:11 UTC | |
by Anonymous Monk on Sep 19, 2019 at 10:54 UTC |