Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical

comment on

( #3333=superdoc: print w/replies, xml ) Need Help??

Thanks for your reply,

I can confirm that by just setting ONLY requests_redirectable => [], LWP::UserAgent does not follow redirects and does not warn about a loop detected.

So, I guess you are asking me to write a documentation patch where to say:

"If you do not want LWP::UserAgent to follow redirects for a certain request then prepare a new array with only the request names you wish redirects to be followed and insert it via requests_redirectable => $array_of_requests_to_follow_redirect . If you do not want LWP::UserAgent to follow ANY request then set this to an empty array ref."

That's no problem, I can do that.

As a side remark (but quite important imo):

when looking at the code of LWP::UserAgent at the place where it gives the loop warning (just search for 'loop') one can see that when the alleged loop is detected, the warning is inserted in the headers AND the sub returns immediately thus omitting code for running the handlers or normalising (absolutising) the Location url from the returned headers and lots of other stuff.

So that "warning" is not that innocent and people should care about it. Maybe it should be clarified. I will agree with the "Anonymous Monk" (Mar 13, 2018 at 20:21 UTC) who considers this as a bug because the logic (with my limited understanding of that code) should be to make a request, increment the redirect count (its name probably is confusing because there is no redirect yet but just one - and maybe the only - request) and then check if that count exceeds the max_redirect limit (and not check if it is equal to it too).

In view of the above, a second documentation patch could go like this:

"Redirect loop detection is a bit petulant and one should not upset it further by demanding zero max_redirect. Notice that max_redirect counts the first request as a redirect. And so if one wants zero redirects, one should set max_redirect to 1 really. The side-effect of LWP::UserAgent detecting a loop and acting on it, appart from inserting a Client-Warning in the response headers, is that the request() will immediately return albeit half-finished. For example no handlers will be run."

In reply to Re^2: LWP::UserAgent : setting max_redirect to 0 yields 'Client-Warning: Redirect loop detected by bliako
in thread LWP::UserAgent : setting max_redirect to 0 yields 'Client-Warning: Redirect loop detected by bliako

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

  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.
  • Log In?

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

    How do I use this? | Other CB clients
    Other Users?
    Others musing on the Monastery: (5)
    As of 2020-01-25 01:29 GMT
    Find Nodes?
      Voting Booth?