3 ms·
I'm sorry, but this is a misunderstanding of the web at a very basic level. In theory, if you read the standard, you ought to be able to return a 402
by JohnBooty 7y ago
I'm sorry, but this is a misunderstanding of the web at a very basic level.
In theory, if you read the standard, you ought
to be able to return a 402 [snip]
Every "problem" you just described applies to 404 as well, and everything handles that just fine.
There is absolutely no problem with servers returning 4xx/5xx codes along with some HTML to render.
All the other things you just described, the content negotiation and so on, are highly debatable at best but the important thing to understand is that they're completely orthogonal to whether or not the server has returned some HTML along with the error code.
You are correct in that human readers don't really know/care whether it's a 4xx/5xx code. But that's fine. They're humans, so it's OK for the HTML returned to give them a choice of what to do.
Non-200 response codes are, of course, already massively useful for other bits of code, for RESTful services and otherwise.
- toast0 7y ago> Every "problem" you just described applies to 404 as well, and everything handles that just fine. I'm not sure what value of everything you're using, but I remember Internet Explorer's 'friendly error messages'. If your html isn't long enough, and that abomination still exists, you'll get Microsoft's 404 instead of your nice and short 404. I have worked with many embedded http clients that can't reliable return content unless it's from an HTTP 200. I wouldn't write one like that, but you don't always get to pick your platform, and some platforms give you HTTP or nothing, so you can't use TCP and do a better job (or more often, you have much more important platform issues to work around than to roll your own http when the platform one works enough and it's trivial to just return 200 in case the server had something to return to the client)
- heavenlyblue 7y agoAlso many libraries are built by throwing exceptions for non-200 error codes.
- JohnBooty 7y agoNo conflict there. For SOAP stuff, an exception on 4xx/5xx is generally a sensible design. For human user-agents (ie, web browsers) there's still no conflict. Deciding whether or not to render some HTML is orthogonal to whether or not some other action might be taken. Generally, you do want to present a choice to the user at this point.
- Sophira 7y ago> If your html isn't long enough, and that abomination still exists, you'll get Microsoft's 404 instead of your nice and short 404. The most annoying part is that this knowledge was abused to make even the most basic and otherwise-useless 404 pages show up in IE. Back when this was a thing, I literally saw this happen. I have one of these pages saved, which is how I know - it was a page which just had "Not Found - The requested document was not found on this server." on it (along with the site name), and then a long HTML comment saying 'Unfortunately, Microsoft has added a clever new "feature" to Internet Explorer.' and explaining the comment's existence. All for a 404 page that gave far less useful information than IE's own 404 page did. If the page had any brand styling on it I might understand, but this was literally a bare-bones, no-styling page with nothing useful on it.
- deleted 7y ago[deleted]