[1] [[HTTPメッセージ]]は、[[頭部]]と[[本体]]の2部で構成されています。 [[頭部]]には、[[本体]]に関する[[メタ情報]]や[[HTTP]]通信に関する制御情報などを[DFN[[RUBY[頭欄] [かしららん] @en[header field]]]]の集合体として記述します。 個々の頭欄は、[[欄名]]と[[欄本体]]の組で構成されます。 [[欄名]]によって識別される[[頭欄]]の種類は、 [[HTTP]]本体規格で規定されている他、 各種周辺規格で追加のものが定義されています。 [2] '''頭欄の分類''': [[頭欄]]は、使われる場所と意味によって4種類に分けられます。 :[[一般頭欄]]: [[HTTP]]通信一般に関わる[[頭欄]]で、多くは[[要求]]でも[[応答]]でも使用されます。 :[[要求頭欄]]: [[HTTP]][[要求]]に関する[[頭欄]]です。 :[[応答頭欄]]: [[HTTP]][[応答]]に関する[[頭欄]]です。 :[[実体頭欄]]: [[HTTP]][[実体]] (or [[実現値]]) に関する[[頭欄]]です。 [[要求]]でも[[応答]]でも使われます。 [3] '''頭欄の種類''': [[頭欄]]は、[[IETF]]の[[RFC]]で規定されているもの、 他の[[標準化団体]]が規定したもの、 規定なしで勝手に使われているものなど色々あります。 長らくこの状況で放置されてきましたが、[[RFC 3864]] (2004年、[[BCP 90]]) によって[[IANA]]登録手続きが成立し、[[RFC 4229]] (2005年) でこれまでに標準化されたものが登録されました。 ;; - [[IANA]] 登録簿: [CITE@en[IANA | Message Header Messages]] - [[RFC 3864]] (登録手続き、[[IETF]] [[BCP 90]]) , - [[RFC 4229]] (初期登録、[[IETF]][[情報提供]]) [[#comment]] * 頭欄一覧 [4] → [[頭欄]]に移動 * 仕様書から ** RFC 1945 (HTTP/1.0); RFC 2068・2616 (HTTP/1.1) 4.2 Message Headers > HTTP header fields, which include [DEL[General-Header (Section 4.3)]] [INS[general-header (section 4.5)]], [DEL[Request-Header (Section 5.2)]] [INS[request-header (section 5.3)]], [DEL[Response-Header (Section 6.2)]] [INS[response-header (section 6.2)]], and [DEL[Entity-Header (Section 7.1)]] [INS[entity-header (section 7.1)]] fields, follow the same generic format as that given in Section 3.1 of RFC 822 [DEL[ [7] ]] [INS[ [9] ]]. Each header field consists of a name followed [DEL[immediately]] by a colon (":")[DEL[, a single space (SP) character,]] and the field value. Field names are case-insensitive. [INS[The field value [DEL[may]] [INS[MAY]] be preceded by any amount of LWS, though a single SP is preferred.]] Header fields can be extended over multiple lines by preceding each extra line with at least one SP or HT[DEL[, though this is not recommended]]. [INS[Applications [DEL[SHOULD]] [INS[ought to]] follow "common form"[INS[, where one is known or indicated,]] when generating HTTP constructs, since there might exist some implementations that fail to accept anything beyond the common forms.]] [DFN[HTTP 頭欄]]は、[[一般頭欄]], [[要求頭欄]], [[応答頭欄]], [[実体頭欄]]を含みますが、 [[RFC822]] の3.1節にある同じ一般書式に従います。 各頭欄は名前、それに[DEL[すぐに]]続くコロン ([CODE(HTTP)[:]])、[DEL[1つの[[間隔]] ([[SP]]) 文字、]]欄値から成ります。 欄名は大文字・小文字を区別しません。[INS[欄値の前には任意の量の [CODE(ABNF)[[[LWS]]]] があって'''構いません'''。しかし [CODE(ABNF)[[[SP]]]] 1つが好ましいです。]] 頭欄は、それぞれの余分な行に最低1つの [CODE(ABNF)[[[SP]]]] または [CODE(ABNF)[[[HT]]]] を入れることで複数行に展開できます。[DEL[ただしこれは推奨しません。]] [INS[応用は、 HTTP 構造体を生成する時に、 [INS[(それが知られているかまたは示されている時には)]]「共通形」に従うべきです。そうしないと、共通形以外のものを受け入れてくれない実装が存在するかもしれません。]] > - [DEL[ HTTP-header = field-name ":" [ field-value ] CRLF]] - [INS[ message-header = field-name ":" [ field-value ] [DEL[CRLF]]]] > - field-name = token - field-value = *( field-content | LWS ) - field-content = [INS[ > [INS[{2616}]] The field-content does not include any leading or trailing LWS: linear white space occurring before the first non-whitespace character of the field-value or after the last non-whitespace character of the field-value. Such leading or trailing LWS MAY be removed without changing the semantics of the field value. Any LWS that occurs between field-content MAY be replaced with a single SP before interpreting the field value or forwarding the message downstream. [CODE(ABNF)[field-content]] は最初や最後の [CODE(ABNF)[LWS]]、つまり [CODE(ABNF)[field-value]] の最初の非空白文字の前や最後の非空白文字の後の[[線形空白]]を含みません。 この最初や最後の [CODE(ABNF)[LWS]] は欄値の意味を変えずに削除して'''構いません'''。 [CODE(ABNF)[field-content]] の間に現れる任意の [CODE(ABNF)[LWS]] は欄値を解釈したりメッセージを[[下流]]に転送したりする前に1つの [CODE(ABNF)[SP]] に置換しても'''構いません'''。 ]INS] > The order in which header fields [INS[with differing field names]] are received is not significant. However, it is "good practice" to send [DEL[General-Header]] [INS[general-header]] fields first, followed by [DEL[Request-Header]] [INS[request-header]] or [DEL[Response-Header]] [INS[response-header]] fields[INS[, and ending with]] [DEL[prior to]] the [DEL[Entity-Header]] [INS[entity-header]] fields. どの順序で[INS[名前の異なる]]頭欄を受信したかは重要ではありません。 しかし、一般頭欄を最初に送り、続けて要求頭欄または応答頭欄を実体頭欄の前に送るのが 「[[良い習慣]]」です。 > Multiple [DEL[HTTP-header]] [INS[message-header]] fields with the same field-name [DEL[[INS[{1945,2068}]] may]] [INS[[INS[{2616}]] MAY]] be present in a message if and only if the entire field-value for that header field is defined as a comma-separated list [i.e., #(values)]. It [DEL[must]] [INS[MUST]] be possible to combine the multiple header fields into one "field-name: field-value" pair, without changing the semantics of the message, by appending each subsequent field-value to the first, each separated by a comma. [INS[The order in which header fields with the same field-name are received is therefore significant to the interpretation of the combined field value, and thus a proxy MUST NOT change the order of these field values when a message is forwarded.]] 同じ [CODE(ABNF)[field-name]] の複数の [CODE(ABNF)[message-header]] は、その頭欄の [CODE(ABNF)[field-value]] 全体が読点分離並び (つまり [CODE(ABNF)[#([VAR[values]])]]) として定義されているときに、 この場合に限って出現して'''構いません'''。 各後続 [CODE(ABNF)[field-value]] を最初のものに、それぞれ読点で分離して後置することによって、 メッセージの意味を変えずに複数の頭欄を一つの [SAMP(HTTP)[[VAR[field-name]]: [VAR[field-value]]]] 組に結合することが可能でなければ'''なりません'''。 [INS[ 注: 注記なき追加・削除は 1945→2068 の差分。 追加部分の中の追加・削除は 2068→2616 の差分。 ]INS] ** RFC の部分のライセンス [[RFCのライセンス]] * メモ [5] [CITE[HTTP interoperability - Anne’s Weblog]] ([TIME[2007-10-14 05:05:32 +09:00]] 版) ([[名無しさん]])