Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl-Sensitive Sunglasses
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??
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.

Thanks!

Gregorovius


In reply to Redirect after POST behavior in LWP::UserAgent differs from Netscape's? by gregorovius

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others romping around the Monastery: (7)
As of 2024-04-19 16:23 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found