/
970.txt
121 lines (88 loc) · 5.13 KB
/
970.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
[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]] 版) <http://tools.ietf.org/html/rfc3875#section-6.3.3>
]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(quote)[
[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 = *<CHAR, excluding CTLs, NL>
]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"
を含める'''べきです'''。
]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: 欄はありません。
** SPDY
[1] [[SPDY]] では [CODE(HTTP)@en[[[status]]]] [[ヘッダー]]が[[状態符号]]を表すために使われていました。
[2] [[HTTP/2]] では [CODE(HTTP)@en[[[:status]]]] [[疑似ヘッダー]]になりました。
* 実装
[19] 元々 [[CGI]] で実装されていて、その後それ以外の [[API]] に移行した [[Webアプリケーション]]で、
あるいはその他の理由で正常に動作していない[[Webアプリケーション]]で、
[CODE(HTTP)@en[[[Status:]]]] 欄が処理されずに[[HTTP]] [[応答]]に含まれることもあります。
[20] [[Apache]] は [[CGI]] だけでなく、 [[send-as-is]] でも [CODE(HTTP)@en[[[Status:]]]]
欄を解釈するようです。
;; as-is じゃないですね・・・。
[21] [CITE@en[RFC 4975 - The Message Session Relay Protocol (MSRP)]]
( ([TIME[2012-02-26 13:20:50 +09:00]] 版))
<http://tools.ietf.org/html/rfc4975#page-37>