How can I get the HTTP status and Location header in Perl? -
I'm new to Pearl, but I need to use it on the project I'm working on. What I need to do is to see if there is a 301 redirect in the URL and if it is, get the spot. The following code told me, but not the location:
use strict; Use warnings; LWP :: User Agent Required; My $ ua = LWP :: UserAgent-> New; $ UA- & gt; Timeout (10); $ UA- & gt; Env_proxy; $ UA- & gt; Max_redirect (0); My $ response = $ ua- & gt; Obtain ('http://www.actwebdesigns.co.uk/'); If ($ response-> is_success) {print $ response-> Position_line; Print $ response- & gt; Progress; } And (dead $ response-> position_line;
Div class = The "post-text" itemprop = "text">
$ response-> header comes from the
method and allows you to inspect the specific headers returned from your request. To locate Location
header, use <$ p>
my $ loc = $ response-> header ('location');
< / Pre>
Comments
Post a Comment