I just upgraded my LWP modules:
$LWP::VERSION = 5.75
$LWP::UserAgent::VERSION = 2.023
and found out that there is a bug in the handling of redirects.When doing $ua->request($post_request), where $post_request is a POST request that returns a redirect (302), and requests_redirectable is unchanged from the default (['GET', 'HEAD']), a redirect *is* performed.
The offending code in LWP/UserAgent, sub request, is:
$referral->method("GET")
if ($code == &HTTP::Status::RC_SEE_OTHER ||
$code == &HTTP::Status::RC_FOUND) &&
$referral->method ne "HEAD"; $referral->url($referral_uri);
$referral->remove_header('Host', 'Cookie');return $response unless $self->redirect_ok($referral);
which always tests whether *GET* is OK to redirect, *not* the original request type.
It seems to me that the right way to fix this, is to change the last line to:
return $response unless $self->redirect_ok($request);
Best regards,
– Michael
