C
CronJob
How do I determine within the program what page I'm on after
LWP::UserAgent follows a redirect? Is there a way I can determine
whether redirects has occurred and if so how many redirects were
followed and what there urls were? (obviously I know what the first
one was)
Code snippet:
sub makeRequest( ) {
($method, $path) = @_;
# create a user agent object
my $ua = new LWP::UserAgent;
$ua->agent("Mozilla/4.0");
# request a url
my $request = new HTTP::Request($method, $path);
# set values in response object HTTP::Reponse
my $response = $ua->request($request);
# get the details if there is an error
# otherwise parse the response object
my $body=$response->content;
my $code=$response->code;
my $desc=HTTP::Status::status_message($code);
my $headers=$response->headers_as_string;
$body = $response->error_as_HTML if ($response->is_error);
return ($code, $desc, $headers, $body);
}
Thanks in advance for any insight.
LWP::UserAgent follows a redirect? Is there a way I can determine
whether redirects has occurred and if so how many redirects were
followed and what there urls were? (obviously I know what the first
one was)
Code snippet:
sub makeRequest( ) {
($method, $path) = @_;
# create a user agent object
my $ua = new LWP::UserAgent;
$ua->agent("Mozilla/4.0");
# request a url
my $request = new HTTP::Request($method, $path);
# set values in response object HTTP::Reponse
my $response = $ua->request($request);
# get the details if there is an error
# otherwise parse the response object
my $body=$response->content;
my $code=$response->code;
my $desc=HTTP::Status::status_message($code);
my $headers=$response->headers_as_string;
$body = $response->error_as_HTML if ($response->is_error);
return ($code, $desc, $headers, $body);
}
Thanks in advance for any insight.