The 4xx set is for operations where the client is at fault: malformed requests, unauthorized or forbidden access, unsatisfiable negotiation requests and so on.

Playing devil's advocate for a 4xx response: When a client requesting https://valid.host/invalid/file.dne gets a 404 from the server, because the file doesn't exist (so the client made a "mistake" by requesting a resource that doesn't exist); this is true even when the true error is that index.html linked to invalid/file.dne and the only "mistake" the client made was trying to download a resource linked from index.html . Likewise, requesting https://invalid.host/index.html from a server that doesn't exist is similarly the client's fault for asking for a server that doesn't exist... but in the absence of a server to tell it that the client made a mistake, it wouldn't be unreasonable for the client to admit "User, I made a mistake in trying to access invalid.host , even though you're the one who asked me to access it". I would even argue for the literal 400 BAD REQUEST response, because it "indicates that the server cannot or will not process the request due to something that is perceived to be a client error (e.g., malformed request syntax, invalid request message framing, or deceptive request routing)." -- where the client error was "asking for a server that doesn't exist (or isn't currently online)"

But similarly, the choice of a 500 error also makes sense: normally, 500 errors are a server's response to an error that it doesn't have better answer for (like "the underlying CGI doesn't know how to generate proper headers" or "doesn't have the proper linux permissions to execute the script"); so when the server is so dissociated that the client cannot see it, I could see the client arbitrarily deciding "this must be a 500, because the server is so confused or messed up that it refuses to respond at all".

But honestly, I think it would be better for LWP::UserAgent to die instead, for reasons given elsewhere in this discussion. That really seems like the best and most natural choice to me.


In reply to Re^2: LWP::UserAgent Client-Warning 500 against HTTP standards? by pryrt
in thread LWP::UserAgent Client-Warning 500 against HTTP standards? by Discipulus

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.