HTTP status code for "cannot complete request for * known cause"

An HTTP 500 means the server cannot complete the request for an unforeseen reason. Which HTTP response code is best used when the server cannot complete the request for a known or expected reason?

http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html https://en.wikipedia.org/wiki/List_of_HTTP_status_codes

looking through some docs over HTTP, I can't find a good answer, and that seems like an important difference. Throwing 500 for an error that does not actually represent an “internal server error” is probably not a good practice.

+7
source share
3

RCF 2616

RFC 2616 , , , . , IETF HTTP QUIC:

RFC2616. , ( ) .

RFC 2616 , HTTP/1.1:

, RFC 7231 - , .

?

:

, RFC 7231, Racksburg:


:

HTTP status codes categories


:

HTTP status codes



2xx 3xx


HTTP 2xx and 3xx status codes



4xx


HTTP 4xx status codes



5xx


HTTP 5xx status codes

+32

http-. , , 401 . , 401 - , , . , , , , .

+1

200 // , , .

, 500 , . 500 , , , .

If what you are looking for is more like "the server can really evaluate the request, but found that what the user asked for some reason is impossible" (for example, some resource has been exhausted), then you probably better off with a status code + 200 + if the reason does not correspond to one of the specific codes in the 4xx range (for example, 403 for "user does not have the necessary privileges").

+1
source

Source: https://habr.com/ru/post/1616640/


All Articles