[12] [DFN[[CODE(HTTP)[[[5xx]]]]]] は、[[鯖]]側のエラーによって[[要求]]を処理できなかったことを示す[[状態符号]]群です。

[FIG(short list)[
- [CODE(HTTP)[[[500]]]]
- [CODE(HTTP)[[[501]]]]
- [CODE(HTTP)[[[502]]]]
- [CODE(HTTP)[[[503]]]]
- [CODE(HTTP)[[[504]]]]
- [CODE(HTTP)[[[505]]]]
- [CODE(HTTP)[[[507]]]]
- [CODE(HTTP)[[[508]]]]
- [CODE(HTTP)[[[510]]]]
- [CODE(HTTP)[[[511]]]]
- [CODE[514]]
]FIG]

* 仕様書

[REFS[
- [8] '''[CITE@en[RFC 7231 - Hypertext Transfer Protocol (HTTP/1.1): Semantics and Content]] ([TIME[2014-08-07 05:54:02 +09:00]] 版) <https://tools.ietf.org/html/rfc7231#section-6.6>'''
- [507] [CITE@en[RFC 7231 - Hypertext Transfer Protocol (HTTP/1.1): Semantics and Content]] ([TIME[2014-08-07 05:54:02 +09:00]] 版) <https://tools.ietf.org/html/rfc7231#section-7.1.1.2>
]REFS]

* 意味

[9] [CODE(HTTP)[[[5xx]]]] は、[[鯖]]自身が異常であると気づいていることや、
指定された[[要求メソッド]]を実行できないことを示します [SRC[>>8]]。

* 構文

[10] [[鯖]]は、[CODE(HTTP)@en[[[HEAD]]]] [[要求メソッド]]の場合を除き、
エラーの状態の説明やそれが一時的なものか永続的なものかの説明を含む[[表現]]を送信する[['''べきです''']]
[SRC[>>8]]。

[508] [CODE(HTTP)[[[5xx]]]] では [CODE(HTTP)@en[[[Date:]]]] [[ヘッダー]]を[[生成]]しなくても良いとされています
[SRC[>>507]]。

;; [509] [CODE(HTTP)[[[5xx]]]] は[[鯖]]の異常状態を表すことがあるので、
[[時刻]]を正しく得られない可能性を考慮してのことでしょう。

* 状態符号の決定

[1] [CODE(HTTP)[[[4xx]]]] を参照。

* 処理

[11] [[利用者エージェント]]は、[[表現]]が含まれていれば[[利用者]]に[[表示]]する[['''べきです''']]
[SRC[>>8]]。

* 歴史

[FIG(quote)[
[FIGCAPTION[
[7] RFC 1945 (HTTP/1.0) 9.5; RFC 2068・RFC 2616 (HTTP/1.1) 10.5 Server Error 5xx
]FIGCAPTION]

> Response status codes beginning with the digit "5" indicate cases in
which the server is aware that it has erred or is incapable of
performing the request. [DEL[If the client has not completed the request when a 5xx code is received, it should immediately cease sending data to the server.]]
Except when responding to a HEAD request, the server [DEL[should]] [INS[SHOULD]]
include an entity containing an explanation of the
error situation, and whether it is a temporary or permanent condition. [INS[User agents SHOULD display any included entity to the user.]] These response codes are applicable to any request method [DEL[and there are no required header fields]].

数字 [CODE(HTTP)[5]] で始まる状態符号は、
サーバーが、自身が誤っているか又は要求を処理する能力がないと知っている場合を示します。 [DEL[[CODE(HTTP)[5[VAR[xx]]]] 符号を受信した時にクライアントがまだ要求を完了させていなければ、クライアントは即座にサーバーにデータを送信するのを止めるべきです。]]
[CODE(HTTP)[[[HEAD]]]] 要求への応答を除いて、サーバーは誤りの状況とそれが一時的な状況なのか永続的な状況なのかの説明を含めた実体を含める'''べきです'''。 [INS[利用者エージェントは、含まれている実体を利用者に表示する'''べきです'''。]]
これらの応答符号はどの要求 method にも適用可能です[DEL[し、必須の頭欄はありません]]。

[INS[
注 : 修正はすべて 1945 → 2068 の差分。
]INS]
]FIG]

[REFS[
- [6] [CITE@en[Web Applications 1.0 r7634     Since this made it likely that overloaded servers would just get even more overloaded, pull back a little and let all 5xx errors stop EventSource reconnects. It still reconnects if the connection drops, though. (Compat: 5xxs don't cause reconnects in deployed browsers currently as far as I can tell.)]]
( ([TIME[2013-01-03 07:23:00 +09:00]] 版))
<http://html5.org/tools/web-apps-tracker?from=7633&to=7634>
]REFS]

* 関連

[506] [[クライアント]]の[[要求]]に関するエラーを表す [CODE(HTTP)[[[4xx]]]]
に対して、 [CODE(HTTP)[[[5xx]]]] は[[鯖]]側のエラーを表します。
通常は [CODE(HTTP)[[[5xx]]]] エラーに対して[[クライアント]]側で対処する方法はありません。

[510] [[クライアント]]は、 [CODE(HTTP)[[[5xx]]]] [[応答]]だけでなく、
[[鯖]]が [CODE(HTTP)[[[5xx]]]] すら返せない状況や、
[[下位層プロトコル]]のエラーも想定して対応できなければなりません。

;; [[HTTP接続]]も参照。