Hi,
If I use LWP to POST to a form to for example
http://www.google.com/post.pl,
How do i let LWP auto redirect if
http://www.google.com/post.pl redirects to
http://www.google.com/post_new.pl ?
A webbrowser usually does this, but LWP won't post to the form.. it won't notice the redirect.
The solution should be somewhere here:
http://cpan.uwinnipeg.ca/htdocs/libwww-perl/LWP/UserAgent.html#ua_gt_requests_redirectableFrom that site:
--- quote ---
$ua->requests_redirectable
$ua->requests_redirectable
( \@requests )
This reads or sets the object's list of request names that $ua->redirect_ok(...) will allow redirection for. By default, this is ['GET', 'HEAD'], as per RFC 2616. To change to include 'POST', consider:
push @{ $ua->requests_redirectable
}, 'POST';
--- /quote ---
But then how do I use $ua->redirect_ok(...), or don't I need to use it ?
All I use is to post is:
$req = (POST $main::aform,[%main::sub_v
], @main::form_headers);
$main::p_html = $main::ua->request($req);
Thank you.