|Just another Perl shrine|
Redirect after POST behavior in LWP::UserAgent differs from Netscape's?by gregorovius (Friar)
|on Mar 16, 2001 at 01:01 UTC||Need Help??|
gregorovius has asked for the
wisdom of the Perl Monks concerning the following question:
Dear fellow Monks,
I'm using LWP::UserAgent to simulate users on a website. The problem I have is that UserAgent behavior after POSTing appears to be different to Netscape's.
When my web application instructs Netscape to redirect (by sending back a 302 Moved message) Netscape will generate a new request which will be a GET request, and discarding the POST parameters of the original request. Netscape, thus, transforms the POST request into a GET request with no content after redirection.
LWP::UserAgent, to begin with, won't follow redirects after posting unless you override the LWP::UserAgent::redirects_ok method to return True for POST requests. Once you do this its behavior for POST redirects will be to issue a new POST request with the same payload (content) of the original request. UserAgent's behavior, thus, is to reissue the exact same request, to the new URL.
I don't know what the HTTP RFC says, but I guess it wouldn't matter, since Netscape's has to be the de-facto standard.
This difference in behaviors is preventing me from reproducing exact user request sequences because my web application assumes that redirects after posting carry no parameters, which is not the case for UserAgent redirects.
I've modified LWP::UserAgent to mimick Netscape's behavior, and now my test sequences pass.
My questions are, do you think this is a bug in LWP::UserAgent, and what the RFC says? A coworker of mine suggests that I submit a patch to LWP for it to do "Netscape emulation". Who do you think is right? I guess the behavior of IE is the same as Netscape's since our web application works fine on it, too.