<html xmlns="http://www.w3.org/1999/xhtml"><head></head><body><p><anchor-end xmlns="urn:x-suika-fam-cx:markup:suikawiki:0:9:" a0:anchor="425" xmlns:a0="urn:x-suika-fam-cx:markup:suikawiki:0:9:">[425]</anchor-end> <dfn><code class="HTTP" xml:lang="en"><anchor xmlns="urn:x-suika-fam-cx:markup:suikawiki:0:9:">Expect:</anchor></code></dfn> <anchor xmlns="urn:x-suika-fam-cx:markup:suikawiki:0:9:">ヘッダー</anchor>は、
<anchor xmlns="urn:x-suika-fam-cx:markup:suikawiki:0:9:">鯖</anchor>の<anchor xmlns="urn:x-suika-fam-cx:markup:suikawiki:0:9:">応答</anchor>の送信に関する<anchor xmlns="urn:x-suika-fam-cx:markup:suikawiki:0:9:">クライアント</anchor>の期待を表明する<anchor xmlns="urn:x-suika-fam-cx:markup:suikawiki:0:9:">要求ヘッダー</anchor>です。</p><section><h1>仕様書</h1><refs xmlns="urn:x-suika-fam-cx:markup:suikawiki:0:9:"><ul xmlns="http://www.w3.org/1999/xhtml"><li><anchor-end xmlns="urn:x-suika-fam-cx:markup:suikawiki:0:9:" a0:anchor="419" xmlns:a0="urn:x-suika-fam-cx:markup:suikawiki:0:9:">[419]</anchor-end> <strong><cite xml:lang="en">RFC 7231 - Hypertext Transfer Protocol (HTTP/1.1): Semantics and Content</cite> (<time>2014-06-07 01:55:45 +09:00</time> 版) <anchor-external xmlns="urn:x-suika-fam-cx:markup:suikawiki:0:9:" a0:resScheme="URI" xmlns:a0="urn:x-suika-fam-cx:markup:suikawiki:0:9:" a0:resParameter="https://tools.ietf.org/html/rfc7231#section-5.1.1">https://tools.ietf.org/html/rfc7231#section-5.1.1</anchor-external></strong></li><li><anchor-end xmlns="urn:x-suika-fam-cx:markup:suikawiki:0:9:" a0:anchor="5" xmlns:a0="urn:x-suika-fam-cx:markup:suikawiki:0:9:">[5]</anchor-end> <cite xml:lang="en">RFC 7231 - Hypertext Transfer Protocol (HTTP/1.1): Semantics and Content</cite> (<time>2014-08-07 05:54:02 +09:00</time> 版) <anchor-external xmlns="urn:x-suika-fam-cx:markup:suikawiki:0:9:" a0:resScheme="URI" xmlns:a0="urn:x-suika-fam-cx:markup:suikawiki:0:9:" a0:resParameter="https://tools.ietf.org/html/rfc7231#page-92">https://tools.ietf.org/html/rfc7231#page-92</anchor-external></li></ul></refs></section><section><h1>意味</h1><p><anchor-end xmlns="urn:x-suika-fam-cx:markup:suikawiki:0:9:" a0:anchor="420" xmlns:a0="urn:x-suika-fam-cx:markup:suikawiki:0:9:">[420]</anchor-end> <code class="HTTP" xml:lang="en"><anchor xmlns="urn:x-suika-fam-cx:markup:suikawiki:0:9:">Expect:</anchor></code> <anchor xmlns="urn:x-suika-fam-cx:markup:suikawiki:0:9:">ヘッダー</anchor>は、
当該<anchor xmlns="urn:x-suika-fam-cx:markup:suikawiki:0:9:">要求</anchor>を正しく処理するために<anchor xmlns="urn:x-suika-fam-cx:markup:suikawiki:0:9:">鯖</anchor>が対応する必要がある特定の動作の集合 
(<rubyb xmlns="urn:x-suika-fam-cx:markup:suikawiki:0:9:">期待<rt xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">expectation</rt></rubyb>) を示すものです <src xmlns="urn:x-suika-fam-cx:markup:suikawiki:0:10:"><anchor-internal xmlns="urn:x-suika-fam-cx:markup:suikawiki:0:9:" a0:anchor="419" xmlns:a0="urn:x-suika-fam-cx:markup:suikawiki:0:9:">&gt;&gt;419</anchor-internal></src>。</p></section><section><h1>構文</h1><p><anchor-end xmlns="urn:x-suika-fam-cx:markup:suikawiki:0:9:" a0:anchor="421" xmlns:a0="urn:x-suika-fam-cx:markup:suikawiki:0:9:">[421]</anchor-end> 値としては、 <code class="HTTP" xml:lang="en"><anchor xmlns="urn:x-suika-fam-cx:markup:suikawiki:0:9:">100-continue</anchor></code> のみが認められています <src xmlns="urn:x-suika-fam-cx:markup:suikawiki:0:10:"><anchor-internal xmlns="urn:x-suika-fam-cx:markup:suikawiki:0:9:" a0:anchor="419" xmlns:a0="urn:x-suika-fam-cx:markup:suikawiki:0:9:">&gt;&gt;419</anchor-internal></src>。
<anchor xmlns="urn:x-suika-fam-cx:markup:suikawiki:0:9:">大文字・小文字不区別</anchor>です <src xmlns="urn:x-suika-fam-cx:markup:suikawiki:0:10:"><anchor-internal xmlns="urn:x-suika-fam-cx:markup:suikawiki:0:9:" a0:anchor="419" xmlns:a0="urn:x-suika-fam-cx:markup:suikawiki:0:9:">&gt;&gt;419</anchor-internal></src>。</p><figure class="railroad"><ul><li><code class="HTTP" xml:lang="en"><anchor xmlns="urn:x-suika-fam-cx:markup:suikawiki:0:9:">100-continue</anchor></code></li></ul></figure></section><section><h1>文脈</h1><p><anchor-end xmlns="urn:x-suika-fam-cx:markup:suikawiki:0:9:" a0:anchor="9" xmlns:a0="urn:x-suika-fam-cx:markup:suikawiki:0:9:">[9]</anchor-end> <anchor xmlns="urn:x-suika-fam-cx:markup:suikawiki:0:9:">HTTP要求</anchor>で指定できます。</p><p><anchor-end xmlns="urn:x-suika-fam-cx:markup:suikawiki:0:9:" a0:anchor="10" xmlns:a0="urn:x-suika-fam-cx:markup:suikawiki:0:9:">[10]</anchor-end> 有効に活用されている例はほとんど見られません。</p><p><anchor-end xmlns="urn:x-suika-fam-cx:markup:suikawiki:0:9:" a0:anchor="11" xmlns:a0="urn:x-suika-fam-cx:markup:suikawiki:0:9:">[11]</anchor-end> <code>Expect:</code> に対応しているとわかっている<anchor xmlns="urn:x-suika-fam-cx:markup:suikawiki:0:9:">HTTPサーバー</anchor>に送信する場合を除き、
使うべきではありません。</p></section><section><h1>処理</h1><p><anchor-end xmlns="urn:x-suika-fam-cx:markup:suikawiki:0:9:" a0:anchor="422" xmlns:a0="urn:x-suika-fam-cx:markup:suikawiki:0:9:">[422]</anchor-end> <code class="HTTP"><anchor xmlns="urn:x-suika-fam-cx:markup:suikawiki:0:9:">100-continue</anchor></code> については、そちらの項を参照してください。</p><p><anchor-end xmlns="urn:x-suika-fam-cx:markup:suikawiki:0:9:" a0:anchor="423" xmlns:a0="urn:x-suika-fam-cx:markup:suikawiki:0:9:">[423]</anchor-end> <anchor xmlns="urn:x-suika-fam-cx:markup:suikawiki:0:9:">鯖</anchor>は、<code class="HTTP" xml:lang="en"><anchor xmlns="urn:x-suika-fam-cx:markup:suikawiki:0:9:">100-continue</anchor></code> 以外を受信した場合、
<code class="HTTP"><anchor xmlns="urn:x-suika-fam-cx:markup:suikawiki:0:9:">417</anchor></code> <anchor xmlns="urn:x-suika-fam-cx:markup:suikawiki:0:9:">応答</anchor>を返して構いません <src xmlns="urn:x-suika-fam-cx:markup:suikawiki:0:10:"><anchor-internal xmlns="urn:x-suika-fam-cx:markup:suikawiki:0:9:" a0:anchor="419" xmlns:a0="urn:x-suika-fam-cx:markup:suikawiki:0:9:">&gt;&gt;419</anchor-internal></src>。</p><comment-p xmlns="urn:x-suika-fam-cx:markup:suikawiki:0:10:"><anchor-end xmlns="urn:x-suika-fam-cx:markup:suikawiki:0:9:" a0:anchor="426" xmlns:a0="urn:x-suika-fam-cx:markup:suikawiki:0:9:">[426]</anchor-end> <code xmlns="http://www.w3.org/1999/xhtml" class="HTTP"><anchor xmlns="urn:x-suika-fam-cx:markup:suikawiki:0:9:">417</anchor></code> を返すことは義務ではないようです。</comment-p></section><section><h1>歴史</h1><section><h1>RFC 2616</h1><p><anchor-end xmlns="urn:x-suika-fam-cx:markup:suikawiki:0:9:" a0:anchor="1" xmlns:a0="urn:x-suika-fam-cx:markup:suikawiki:0:9:">[1]</anchor-end> この欄は <anchor xmlns="urn:x-suika-fam-cx:markup:suikawiki:0:9:">RFC 2616</anchor> ではじめて導入されました。</p><figure class="quote"><figcaption><anchor-end xmlns="urn:x-suika-fam-cx:markup:suikawiki:0:9:" a0:anchor="418" xmlns:a0="urn:x-suika-fam-cx:markup:suikawiki:0:9:">[418]</anchor-end> RFC 2616 (HTTP/1.1) 14.20 Expect</figcaption><blockquote><p>The Expect request-header field is used to indicate that particular
server behaviors are required by the client.</p></blockquote><p><code class="HTTP">Expect</code> 要求頭欄は、クライアントが必要としている特定のサーバーの動作を示すのに使います。</p><blockquote><ul><li>Expect       =  &quot;Expect&quot; &quot;:&quot; 1#expectation</li></ul><ul><li>expectation  =  &quot;100-continue&quot; | expectation-extension</li><li>expectation-extension =  token [ &quot;=&quot; ( token | quoted-string ) *expect-params ]</li><li>expect-params =  &quot;;&quot; token [ &quot;=&quot; ( token | quoted-string ) ]</li></ul></blockquote><blockquote><p>A server that does not understand or is unable to comply with any of
the expectation values in the Expect field of a request MUST respond
with appropriate error status. The server MUST respond with a 417
(Expectation Failed) status if any of the expectations cannot be met
or, if there are other problems with the request, some other 4xx status.</p></blockquote><p>サーバーは要求中の <code class="HTTP">Expect</code> 欄の期待値のいずれかが理解できないか又は完了できないなら、
適当な誤り状態で応答しなければ<strong>なりません</strong>。
サーバーは、期待のいずれかを満たすことができないなら
<code class="HTTP"><anchor xmlns="urn:x-suika-fam-cx:markup:suikawiki:0:9:">417</anchor></code> (期待失敗) 状態で応答しなければ<strong>なりません</strong>。
要求にその他の問題があったなら、他の <code class="HTTP">4<var>xx</var></code>
状態で応答しなければ<strong>なりません</strong>。</p><blockquote><p>This header field is defined with extensible syntax to allow for
future extensions. If a server receives a request containing an
Expect field that includes an expectation-extension that it does not
support, it MUST respond with a 417 (Expectation Failed) status.</p></blockquote><p>この頭欄は将来の拡張のために拡張可能な構文で定義しています。
サーバーが対応していない <code class="ABNF">expectation-extension</code>
を含む <code class="HTTP">Expect</code> 欄を含む要求を受け取ったなら、
<code class="HTTP">417</code> (期待失敗) 状態で応答しなければ<strong>なりません</strong>。</p><blockquote><p>Comparison of expectation values is case-insensitive for unquoted
tokens (including the 100-continue token), and is case-sensitive for
quoted-string expectation-extensions.</p></blockquote><p>期待値の比較は引用符で囲まれていない字句 (<code class="HTTP">100-continue</code>
字句を含む。) は大文字・小文字を区別せず、
<code class="ABNF"><anchor xmlns="urn:x-suika-fam-cx:markup:suikawiki:0:9:">quoted-string</anchor></code> <code class="ABNF">expectation-extensions</code>
は大文字・小文字を区別して行います。</p><blockquote><p>The Expect mechanism is hop-by-hop: that is, an HTTP/1.1 proxy MUST
return a 417 (Expectation Failed) status if it receives a request
with an expectation that it cannot meet. However, the Expect
request-header itself is end-to-end; it MUST be forwarded if the
request is forwarded.</p></blockquote><p><code class="HTTP">Expect</code> 機構は hop‐by‐by です。
つまり、 HTTP/1.1 串はその満たすことのできない期待をもつ要求を受け取ったときには
<code class="HTTP">417</code> (期待失敗) 状態を返さなければ<strong>なりません</strong>。
しかし、 <code class="HTTP">Expect</code> 要求頭自体は末端対末端です。
要求が転送される時に転送されなければ<strong>なりません</strong>。</p><blockquote><p>Many older HTTP/1.0 and HTTP/1.1 applications do not understand the
Expect header.</p></blockquote><p>古い HTTP/1.0 応用や HTTP/1.1 応用の多くは <code class="HTTP">Expect</code>
頭を理解しません。</p><blockquote><p>See section 8.2.3 for the use of the 100 (continue) status.</p></blockquote></figure></section><section><h1>RFC 7231</h1><p><anchor-end xmlns="urn:x-suika-fam-cx:markup:suikawiki:0:9:" a0:anchor="424" xmlns:a0="urn:x-suika-fam-cx:markup:suikawiki:0:9:">[424]</anchor-end> <anchor xmlns="urn:x-suika-fam-cx:markup:suikawiki:0:9:">RFC 2616</anchor> では <code class="HTTP"><anchor xmlns="urn:x-suika-fam-cx:markup:suikawiki:0:9:">100</anchor></code> 
を求める機能と理解必須の拡張を示す一般的な仕組みとの2つの機能を
<code class="HTTP" xml:lang="en"><anchor xmlns="urn:x-suika-fam-cx:markup:suikawiki:0:9:">Expect:</anchor></code> が担っていましたが、
<anchor xmlns="urn:x-suika-fam-cx:markup:suikawiki:0:9:">クライアント</anchor>も<anchor xmlns="urn:x-suika-fam-cx:markup:suikawiki:0:9:">鯖</anchor>も拡張機能は実装していないどころか壊れている <src xmlns="urn:x-suika-fam-cx:markup:suikawiki:0:10:"><anchor-internal xmlns="urn:x-suika-fam-cx:markup:suikawiki:0:9:" a0:anchor="5" xmlns:a0="urn:x-suika-fam-cx:markup:suikawiki:0:9:">&gt;&gt;5</anchor-internal></src>
とされ、利用価値がないとして削除して簡略化されました <src xmlns="urn:x-suika-fam-cx:markup:suikawiki:0:10:"><anchor-internal xmlns="urn:x-suika-fam-cx:markup:suikawiki:0:9:" a0:anchor="419" xmlns:a0="urn:x-suika-fam-cx:markup:suikawiki:0:9:">&gt;&gt;419</anchor-internal></src>。</p></section></section><section><h1>関連</h1><p><anchor-end xmlns="urn:x-suika-fam-cx:markup:suikawiki:0:9:" a0:anchor="2" xmlns:a0="urn:x-suika-fam-cx:markup:suikawiki:0:9:">[2]</anchor-end> 似た欄として <anchor xmlns="urn:x-suika-fam-cx:markup:suikawiki:0:9:">RTSP</anchor> (<anchor xmlns="urn:x-suika-fam-cx:markup:suikawiki:0:9:">RFC 2326</anchor>) の <code class="RTSP"><anchor xmlns="urn:x-suika-fam-cx:markup:suikawiki:0:9:">Require</anchor></code>, <code class="RTSP"><anchor xmlns="urn:x-suika-fam-cx:markup:suikawiki:0:9:">Proxy-Require</anchor></code> があります。 <weak xmlns="urn:x-suika-fam-cx:markup:suikawiki:0:9:">(HTTP と RTSP の WG が密に連絡取ってれば統一できたんじゃないかなあ。。。)</weak></p><ul><li><anchor-end xmlns="urn:x-suika-fam-cx:markup:suikawiki:0:9:" a0:anchor="3" xmlns:a0="urn:x-suika-fam-cx:markup:suikawiki:0:9:">[3]</anchor-end> HTTP/1.1 内にも似た欄として <code class="HTTP"><anchor xmlns="urn:x-suika-fam-cx:markup:suikawiki:0:9:">Upgrade</anchor></code> があります。</li><li><anchor-end xmlns="urn:x-suika-fam-cx:markup:suikawiki:0:9:" a0:anchor="4" xmlns:a0="urn:x-suika-fam-cx:markup:suikawiki:0:9:">[4]</anchor-end> <anchor-internal xmlns="urn:x-suika-fam-cx:markup:suikawiki:0:9:" a0:anchor="3" xmlns:a0="urn:x-suika-fam-cx:markup:suikawiki:0:9:">&gt;&gt;3</anchor-internal> 使い分けは、現在使用中のプロトコルに上乗せする機能を示すのが <code class="HTTP">Expect</code>, 現在のプロトコルの代わりに使うのが <code class="HTTP">Upgrade</code> でしょうか。</li></ul><p><anchor-end xmlns="urn:x-suika-fam-cx:markup:suikawiki:0:9:" a0:anchor="7" xmlns:a0="urn:x-suika-fam-cx:markup:suikawiki:0:9:">[7]</anchor-end> <code class="HTTP" xml:lang="en"><anchor xmlns="urn:x-suika-fam-cx:markup:suikawiki:0:9:">Man:</anchor></code> <anchor xmlns="urn:x-suika-fam-cx:markup:suikawiki:0:9:">ヘッダー</anchor>もありますが、そちらは機能を直接指定するものではなく、<anchor xmlns="urn:x-suika-fam-cx:markup:suikawiki:0:9:">名前空間</anchor>により間接的に要求するものとなっています。</p><p><anchor-end xmlns="urn:x-suika-fam-cx:markup:suikawiki:0:9:" a0:anchor="6" xmlns:a0="urn:x-suika-fam-cx:markup:suikawiki:0:9:">[6]</anchor-end> 必須でなく希望を伝える<anchor xmlns="urn:x-suika-fam-cx:markup:suikawiki:0:9:">ヘッダー</anchor>として、新たに
<code class="HTTP" xml:lang="en"><anchor xmlns="urn:x-suika-fam-cx:markup:suikawiki:0:9:">Prefer:</anchor></code> が追加されています。</p><p><anchor-end xmlns="urn:x-suika-fam-cx:markup:suikawiki:0:9:" a0:anchor="427" xmlns:a0="urn:x-suika-fam-cx:markup:suikawiki:0:9:">[427]</anchor-end> <cite xml:lang="en">draft-goland-http-reliability-00 - SOA-Reliability (SOA-Rity) for HTTP</cite>
( (<time>2014-11-18 19:45:11 +09:00</time> 版))
<anchor-external xmlns="urn:x-suika-fam-cx:markup:suikawiki:0:9:" a0:resScheme="URI" xmlns:a0="urn:x-suika-fam-cx:markup:suikawiki:0:9:" a0:resParameter="https://tools.ietf.org/html/draft-goland-http-reliability-00#appendix-A.7">https://tools.ietf.org/html/draft-goland-http-reliability-00#appendix-A.7</anchor-external></p><figure class="quote"><figcaption><anchor-end xmlns="urn:x-suika-fam-cx:markup:suikawiki:0:9:" a0:anchor="8" xmlns:a0="urn:x-suika-fam-cx:markup:suikawiki:0:9:">[8]</anchor-end> <cite>WebRequestのExpectにデフォルトで100-continueがつく件 - 初学者の箸置</cite>
( (<time>2017-07-27 02:35:49 +09:00</time>))
<anchor-external xmlns="urn:x-suika-fam-cx:markup:suikawiki:0:9:" a0:resScheme="URI" xmlns:a0="urn:x-suika-fam-cx:markup:suikawiki:0:9:" a0:resParameter="http://d.hatena.ne.jp/tkuro/20110208/1297181393">http://d.hatena.ne.jp/tkuro/20110208/1297181393</anchor-external></figcaption><blockquote><p>.NETにて簡単にHTTP接続するにはWebRequestを使う訳なのですが、これがデフォルトでは強制的に Expect: 100-continueを送るように固定されていて</p></blockquote></figure></section></body></html>