[11] [[CGI応答]]で使われる[[CGI欄]] [DFN[[CODE(HTTP)@en[[[Status:]]]]]] は、 [[応答]]の[[状態符号]]を指定します。 * 仕様書 [REFS[ - [10] [CITE@en[RFC 3875 - The Common Gateway Interface (CGI) Version 1.1]] ([TIME[2011-11-20 06:09:05 +09:00]] 版) ]REFS] * 構文 [12] この[[欄]]の値の構文は次のように定義されています [SRC[>>10]]。 [PRE(ABNF code)[ Status = "Status:" status-code SP reason-phrase NL status-code = "200" | "302" | "400" | "501" | extension-code extension-code = 3digit reason-phrase = *TEXT ]PRE] ;; [13] なぜ4つだけあえて定義されているのはよくわかりませんが・・・。 [14] この欄には [[HTTP]] [[状態符号]]と、それに併記する事由を指定します。 ;; [15] [[プロトコル]]非依存を装ってる [[CGI]] の [[RFC]] ですが、ここだけはなぜかというか流石にというか、 [[HTTP]] のことしか書いてなくて他の[[プロトコル]]の存在を完全に無視していますww [16] [CODE(HTTP)@en[[[Status:]]]] 欄は[[局所リダイレクト応答]]では使えませんが、それ以外の[[CGI応答]]で使うことができます。 [17] この欄の値が不適切なときの[[鯖]]の処理は明記されていません。 [18] この欄の値は必ずしも[[スクリプト]]の[[誤り]]の状況でなくても構いません。例えば、[[鯖]]の[[誤り]]の処理のために [[CGIスクリプト]]が呼ばれている場合、その[[鯖]]の[[誤り]]の状況を説明する[[状態符号]]を使うべきです。 [SRC[>>10]] *歴史 ** CGI/1.1 (coar draft 03) [FIG(quotation)[ [FIGCAPTION[ [9] 7.2.1.3. Status ]FIGCAPTION] >The "Status" header field is used to indicate to the server what status code the server MUST use in the response message. "Status" 頭欄はサーバーがどの状態符号を応答メッセージに使わ'''なければならない''' かをサーバーに示すのに使います。 [PRE[ Status = "Status" ":" digit digit digit SP reason-phrase NL reason-phrase = * ]PRE] [PRE[ The valid status codes are listed in section 6.1.1 of the HTTP/1.0 specifications [3]. If the SERVER_PROTOCOL is "HTTP/1.1", then the status codes defined in the HTTP/1.1 specification [8] may be used. If the script does not return a "Status" header field, then "200 OK" SHOULD be assumed by the server. ]PRE] 妥当な状態符号は HTTP/1.0 仕様書の 6.1.1節に列挙されています。 [[SERVER_PROTOCOL]] が "HTTP/1.1" の場合、状態符号は HTTP/1.1 で定義されているものを使って構いません。 Script が "Status" 頭欄を返さない場合は、 "200 OK" がサーバーにより 仮定される'''べきです'''。 [PRE[ If a script is being used to handle a particular error or condition encountered by the server, such as a '404 Not Found' error, the script SHOULD use the "Status" CGI header field to propagate the error condition back to the client. E.g., in the example mentioned it SHOULD include a "Status: 404 Not Found" in the header data returned to the server. ]PRE] Script がサーバーの遭遇した特定の誤り又は状態, 例えば「404 Not Found」誤りを取り扱うのに使われる場合、 script は顧客に誤り状態を伝えるために "Status" CGI 頭欄を使う'''べきです'''。 例えばこの例では、サーバーに返される頭データに "Status: 404 Not Found" を含める'''べきです'''。 * RFC の部分の License [[RFCのライセンス]] ]FIG] ** BNF = Status = "Status:" [WSP] Status-Code SP Reason-Phrase = Status-Code = 3DIGIT = Reason-Phrase = cgi-rtext / http-rtext = cgi-rtext = %x20-7E = http-rtext = %x09 / %x20-7E / %x80-FF [[HTTP応答]]の staus-line では Reason-Phrase は OCTET - CTL + LWS - CR - LF で定義されているのですが、 CGI/1.1 では CHAR - CTL ですから、 CGI の方が使える文字が少ないことになります。 参考までに、 = sip-rtext = %x09 / %x20-7E / UTF8-xtra です。が、 [[SIP-CGI]] に Status: 欄はありません。