Do you want it to be silent for the redirection? Use a simple_request instead of request.
my $ua = LWP::UserAgent->new; my $uri = shift @ARGV; my $headreq = HTTP::Request->new(HEAD => $uri); my $headres = $ua->simple_request($headreq); # <---- my $statuscode = $headres->code(); print "Status 401 at $uri\n" if $statuscode == 401;
Or do you wish for it to display the uri to which you were redirected? Access it through the Request that produced the Response.
my $ua = LWP::UserAgent->new; my $uri = shift @ARGV; my $headreq = HTTP::Request->new(HEAD => $uri); my $headres = $ua->request($headreq); my $statuscode = $headres->code(); if ($statuscode == 401) { my $final_uri = $headres->request()->uri(); # <---- print "Status 401 at $final_uri\n" }
In reply to Re: HTTP status codes
by ikegami
in thread HTTP status codes
by memwaster
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |