Beefy Boxes and Bandwidth Generously Provided by pair Networks
Don't ask to ask, just ask
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??

To answer to your question the RFC2616 says:

If the 301 status code is received in response to a request other than GET or HEAD, the user agent MUST NOT automatically redirect the request unless it can be confirmed by the user, since this might change the conditions under which the request was issued.
Note: When automatically redirecting a POST request after receiving a 301 status code, some existing HTTP/1.0 user agents will erroneously change it into a GET request.


For yor other question : You can make a new MyUa.pm redefining only redirect_ok (or modified UserAgent.pm, but it's dirty) to follow your rules.
#!/usr/bin/pl package MyUa; use LWP::UserAgent; @ISA = "LWP::UserAgent"; sub redirect_ok { # here depending on what you've decided # you return true to follow the redirect # or false to not follow # (we set up the return value depending on # other (previously set up) variable to achieve our goal) # # You can also set some variables here to to modify the way # you'll retrive the new pages elsewhere in your prog/in the LWP #(argh, dirty !) # to change POST to GET by example... } 1;

At the office we have configured 3 different behaviour for redirect on POST :

Strict RFC compliance->don't follow to new location.
'Rfc erroneous' mode->follow to new location but with a get (as the RFC say you shouldn't POST automatically to the new location.
Weird mode(but usefull)-> where we POST to the new location.

I must precise that ALL these modes are needed as we found, in real life, sites that needs one of these modes...

In reply to Re: make useragent follow redirects in post actions by arhuman
in thread make useragent follow redirects in post actions by Specimen

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 browsing the Monastery: (2)
As of 2024-04-26 04:13 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found