Subject: | LWP::UserAgent |
Date: | Thu, 17 Feb 2011 16:41:32 -0500 |
To: | bug-libwww-perl [...] rt.cpan.org |
From: | Édouard Henrion <edouard.henrion [...] crchum.qc.ca> |
Hi,
Since I upgraded to perl 5.10, I cannot use the LWP::UserAgetn module :
it always returns a 302 error (Not Allowed) when I try to "post", and a
401 (Unauthorized) when I try to "get"
Here is an example of a code that works fine with perl 5.8 (returns me
the content of the web page) and does not work with perl 5.10 (always
reach the 'print $res->status_line, "\n";' instruction...) :
# Create a user agent object
use LWP::UserAgent;
my $ua = LWP::UserAgent->new;
$ua->agent("MyApp/0.1 ");
# Create a request
my $req = HTTP::Request->new(POST => 'http://search.cpan.org/search');
$req->content_type('application/x-www-form-urlencoded');
$req->content('query=libwww-perl&mode=dist');
# Pass request to the user agent and get a response back
my $res = $ua->request($req);
# Check the outcome of the response
if ($res->is_success) {
print $res->content;
}
else {
print $res->status_line, "\n";
}
Have you ever heard of such a behaviour ?
Is it really related to the version of Perl ?
What should I do to make it work ?
Thanks a lot !
Édouard