Greetings Monks, Seekers, and Browsers.

When using LWP::UserAgent to access web sites, I note that it tries very hard to make things appear simple. Things are often not, however, actually simple. For instance: If the host returns a 500 error, LWP returns a 500 error to the caller. If the host doesn't answer, LWP returns a 500 error. This is not the truth. If you can't contact the host, you can't get an error code, including 500. If the host has no DNS entry, you get a 500 error. If the network is down, you get a 500 error. So you see where I am going. If you need to know what really happened, you have to follow-up every 500 error with some kind of troubleshooting. Same with a 400 error. If LWP doesn't like the URL, you get a 400 error just as if you had really contacted the host.

It occurs to me that LWP has to go through all the steps of contacting DNS, contacting the host, etc. So LWP must discover whether DNS is reachable, and whether there is a record for the host, and whether the host was actually contacted. It knows, but it won't say. I have expended a lot of time going through documentation (erm...) and code (yikes! The swamp is eating me alive!) at CPAN and can't find a solution.

So I ask you: Is there any way to get LWP to give up the information?


In reply to beyond LWP return code by Anonymous Monk

Title:
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, details, 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, summary, 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.