[1] [DFN[[CODE(HTTP)@en[[[TE:]]]]]] [[ヘッダー]]は、[[クライアント]]が受け付ける意志がある[[転送符号化]]を表します。

* 仕様書

[REFS[
- [2] '''[CITE@en[RFC 7230 - Hypertext Transfer Protocol (HTTP/1.1): Message Syntax and Routing]] ([TIME[2014-06-07 01:59:35 +09:00]] 版) <https://tools.ietf.org/html/rfc7230#section-4.3>'''
- [22] [CITE@en[RFC 7540 - Hypertext Transfer Protocol Version 2 (HTTP/2)]] ([TIME[2015-05-15 10:14:54 +09:00]] 版) <https://tools.ietf.org/html/rfc7540#section-8.1.2.2>
]REFS]

* 意味

[17] [CODE(HTTP)@en[[[TE:]]]] [[ヘッダー]]は、[[クライアント]]が受け付ける意志がある
(処理できる) [[転送符号化]](群)を指定するものです。

[11] [CODE(HTTP)[[[TE:]]]] [[ヘッダー]]がないか、空の時は、
[CODE(HTTP)[[[chunked]]]] [[符号化]]のみ受け入れられることを表します [SRC[>>2]]。

;; [18] 仕様上明記されていませんが、[[ヘッダー]]の値が[[非妥当]]の時も、
そのように解釈するべきと思われます。

[12] なお、[[転送符号化]]を使用しないことは、常に受け入れられると考えます [SRC[>>2]]。
つまり、 [CODE(HTTP)@en[[[TE:]]]] [[ヘッダー]]の有無や値に関わらず、
[[鯖]]は常に無変換で元の[[バイト列]]をそのまま送ることができます。

* 構文

[3] この[[ヘッダー]]の値は0個以上の値の[[リスト]] ([CODE[#]]) です。
[[リスト]]の各項目は[[転送符号化]]の名前と[[引数]]です。 [SRC[>>2]]

[FIG(railroad)[
= ?
== [[転送符号化]]の名前と[[引数]]
== *
=== [[FWS]]
=== [CODE(HTTP)[[[,]]]]
=== [[FWS]]
=== [[転送符号化]]の名前と[[引数]]
]FIG]

;; [5] [[転送符号化]]の項を参照してください。

[6] 名前として [CODE(HTTP)@en[[[chunked]]]] を指定しては[['''なりません''']] [SRC[>>2]]。

;; [7] [[HTTP/1.1]] では [CODE(HTTP)@en[[[chunked]]]] への対応は必須となっているので、
明記する必要性がありません。

[8] [[転送符号化]]のかわりに特別な値 [CODE(HTTP)@en[[[trailers]]]]
([[大文字・小文字不区別]]) を指定することができます [SRC[>>2]]。

[9] 仕様上完全に明確ではありませんが、 [CODE(HTTP)@en[[[trailers]]]]
には[[引数]]を指定できないようです。

[10] [[転送符号化]]の名前と[[引数]]の後には、特別な [CODE(HTTP)[[[q]]]]
[[引数]]を指定できます。詳しくは [CODE(HTTP)[[[q]]]] の項を参照してください。

[23] [[HTTP/2]] では、 [CODE(HTTP)@en[[[trailers]]]] 以外の値を指定しては[['''なりません''']]
[SRC[>>22]]。

* 文脈

[16] この[[ヘッダー]]は[[クライアント]]が[[要求]]に指定します。

[4] この[[ヘッダー]]は、複数指定できます。

[15] [[送信者]]は [CODE(HTTP)@en[[[TE:]]]] を用いるときは
[CODE(HTTP)@en[[[Connection:]]]] に [CODE(HTTP)[[[TE]]]]
を含めなければ[['''なりません''']] [SRC[>>2]]。

* 処理

[19] [[鯖]]は、[[応答]]を[[送信]]する際に[[要求]]で受け入れると表明された[[転送符号化]]から適切なものを選ぶことになります。

[13] 複数の[[転送符号化]]を受け入れられるときは、 [CODE(HTTP)@en[[[q]]]]
[[引数]]があればその値が優先度を表します。

;; [14] [CODE(HTTP)[[[q]]]] [[引数]]がないときや、同位の値があるときの解釈は明記されていません。

[21] なお、 [[HTTP/1.0]] の[[要求]]の場合、 [CODE(HTTP)@en[[[TE:]]]] [[ヘッダー]]の有無に関わらず、
[[転送符号化]]は認められていません。

;; [20] [[転送符号化]]の項も参照。

* 歴史

[FIG(quote)[
[FIGCAPTION[
RFC 2616 (HTTP/1.1) 14.39 TE
]FIGCAPTION]

> The TE request-header field indicates what extension transfer-codings
it is willing to accept in the response and whether or not it is
willing to accept trailer fields in a chunked transfer-coding. Its
value may consist of the keyword "trailers" and/or a comma-separated
list of extension transfer-coding names with optional accept
parameters (as described in section 3.6).

TE 要求頭欄は、応答でどの拡張転送符号化を受け入れる意思があるかや、
chunked (塊) 転送符号化で trailers 欄を受け入れる意思があるか否か
を示します。値は、キーワード「trailers」と読点(comma)区切りの
拡張転送符号化の名前, 必要があれば受け入れパラメーター (3.6節で説明) 
の一覧の両方または一方を取ることが出来ます。

[PRE[
       TE        = "TE" ":" #( t-codings )
       t-codings = "trailers" | ( transfer-extension [ accept-params ] )
]PRE]

The presence of the keyword "trailers" indicates that the client is
willing to accept trailer fields in a chunked transfer-coding, as defined in 
section 3.6.1. This keyword is reserved for use with transfer-coding 
values even though it does not itself represent a transfer-coding.

「trailers」キーワードが現れた場合、クライアントは chunked (塊)
転送符号化において3.6.1節で定義されたように、 trailers 欄を
受け入れる意思があることを示します。このキーワードは、転送符号化を
表すものではありませんが、転送符号化値と同様に使うのに予約します。

Examples of its use are: 使用例:

- TE: deflate
- TE:
- TE: trailers, deflate;q=0.5

The TE header field only applies to the immediate connection.
Therefore, the keyword MUST be supplied within a Connection header
field (section 14.10) whenever TE is present in an HTTP/1.1 message.

TE 頭欄は、直後の接続にのみ適用されます。ですから、
TE が HTTP/1.1 メッセージ中に出現する場合は必ず、キーワードが 
Connection 頭欄 (14.10節) 中にも供給され'''なければなりません'''。

A server tests whether a transfer-coding is acceptable, according to
a TE field, using these rules:

サーバーは、 TE 欄により次の規則を使って、転送符号化が使えるかどうかを
確認します。

1. The "chunked" transfer-coding is always acceptable. If the keyword 
"trailers" is listed, the client indicates that it is willing to accept 
trailer fields in the chunked response on behalf of itself and any downstream 
clients. The implication is that, if given, the client is stating that either 
all downstream clients are willing to accept trailer fields in the forwarded 
response, or that it will attempt to buffer the response on behalf of 
downstream recipients.

[PRE[
         Note: HTTP/1.1 does not define any means to limit the size of a
         chunked response such that a client can be assured of buffering
         the entire response.
]PRE]

[PRE[
      2. If the transfer-coding being tested is one of the transfer-
         codings listed in the TE field, then it is acceptable unless it
         is accompanied by a qvalue of 0. (As defined in section 3.9, a
         qvalue of 0 means "not acceptable.")
]PRE]

[PRE[
      3. If multiple transfer-codings are acceptable, then the
         acceptable transfer-coding with the highest non-zero qvalue is
         preferred.  The "chunked" transfer-coding always has a qvalue
         of 1.
]PRE]

If the TE field-value is empty or if no TE field is present, the only 
transfer-coding  is "chunked". A message with no transfer-coding is always 
acceptable.

TE 欄値が空か、 TE 欄が存在しない場合、転送符号化「chunked」(塊)
だけが使えます。転送符号化の無いメッセージは常に認められます。
]FIG]