<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="2" xmlns:a0="urn:x-suika-fam-cx:markup:suikawiki:0:9:">[2]</anchor-end> <dfn><code class="HTTP">2<var>xx</var></code></dfn> は、成功を表す<anchor xmlns="urn:x-suika-fam-cx:markup:suikawiki:0:9:">状態符号</anchor>です。</p><figure class="short list"><ul><li><code class="HTTP"><anchor xmlns="urn:x-suika-fam-cx:markup:suikawiki:0:9:">200</anchor></code></li><li><code class="HTTP"><anchor xmlns="urn:x-suika-fam-cx:markup:suikawiki:0:9:">201</anchor></code></li><li><code class="HTTP"><anchor xmlns="urn:x-suika-fam-cx:markup:suikawiki:0:9:">202</anchor></code></li><li><code class="HTTP"><anchor xmlns="urn:x-suika-fam-cx:markup:suikawiki:0:9:">203</anchor></code></li><li><code class="HTTP"><anchor xmlns="urn:x-suika-fam-cx:markup:suikawiki:0:9:">204</anchor></code></li><li><code class="HTTP"><anchor xmlns="urn:x-suika-fam-cx:markup:suikawiki:0:9:">206</anchor></code></li><li><code class="HTTP"><anchor xmlns="urn:x-suika-fam-cx:markup:suikawiki:0:9:">207</anchor></code></li><li><code class="HTTP"><anchor xmlns="urn:x-suika-fam-cx:markup:suikawiki:0:9:">226</anchor></code></li></ul></figure><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="1" xmlns:a0="urn:x-suika-fam-cx:markup:suikawiki:0:9:">[1]</anchor-end> <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-6.3">https://tools.ietf.org/html/rfc7231#section-6.3</anchor-external></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-US">Fetch Standard</cite> (<time>2015-09-07 19:46:18 +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://fetch.spec.whatwg.org/#ok-status">https://fetch.spec.whatwg.org/#ok-status</anchor-external></li></ul></refs></section><section><h1>意味</h1><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:">Fetch Standard</anchor> は <code><anchor xmlns="urn:x-suika-fam-cx:markup:suikawiki:0:9:">200</anchor></code> <anchor xmlns="urn:x-suika-fam-cx:markup:suikawiki:0:9:">以上</anchor> <code><anchor xmlns="urn:x-suika-fam-cx:markup:suikawiki:0:9:">299</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>を
<dfn><rubyb xmlns="urn:x-suika-fam-cx:markup:suikawiki:0:9:">OK状態<rt xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">ok status</rt></rubyb></dfn>と定義しています <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>。</p></section><section><h1>成功との判断</h1><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> <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="8" xmlns:a0="urn:x-suika-fam-cx:markup:suikawiki:0:9:">[8]</anchor-end> <anchor xmlns="urn:x-suika-fam-cx:markup:suikawiki:0:9:">Web API</anchor> の呼び出しなどの極めて単純な <anchor xmlns="urn:x-suika-fam-cx:markup:suikawiki:0:9:">HTTPクライアント</anchor>による
<anchor xmlns="urn:x-suika-fam-cx:markup:suikawiki:0:9:">HTTP要求</anchor>を送信して<anchor xmlns="urn:x-suika-fam-cx:markup:suikawiki:0:9:">応答</anchor>を受信するケースでは、
例えば<anchor xmlns="urn:x-suika-fam-cx:markup:suikawiki:0:9:">HTTPキャッシュ</anchor>等を使わないので <code class="HTTP">206</code> や <code class="HTTP">304</code>
を成功と判断する必要がなかったり (むしろ想定外なのでエラーと判断するべきだったり) します。
あるいは <code>207</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="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:">状態符号</anchor>と考えられます。<figure class="short list"><ul><li><code class="HTTP">200</code></li><li><code class="HTTP">201</code></li><li><code class="HTTP">202</code></li><li><code class="HTTP">203</code></li><li><code class="HTTP">204</code></li></ul></figure></p><p><anchor-end xmlns="urn:x-suika-fam-cx:markup:suikawiki:0:9:" a0:anchor="16" xmlns:a0="urn:x-suika-fam-cx:markup:suikawiki:0:9:">[16]</anchor-end> 
どのように判定されるかわからないケースでは、保守的に常に <code>200</code>
を返す方がいいかもしれません。</p><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="11" xmlns:a0="urn:x-suika-fam-cx:markup:suikawiki:0:9:">[11]</anchor-end> <cite>Webhooks</cite>, <time>2024-07-08T03:19:05.000Z</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://developer.vonage.com/en/getting-started/concepts/webhooks#receiving-webhooks">https://developer.vonage.com/en/getting-started/concepts/webhooks#receiving-webhooks</anchor-external></li><li><anchor-end xmlns="urn:x-suika-fam-cx:markup:suikawiki:0:9:" a0:anchor="13" xmlns:a0="urn:x-suika-fam-cx:markup:suikawiki:0:9:">[13]</anchor-end> <cite>Vonage Olympus API (v1.0) Reference | Vonage API Documentation</cite>, <time>2024-07-08T03:19:39.000Z</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://developer.vonage.com/en/api/messages-olympus#websockets">https://developer.vonage.com/en/api/messages-olympus#websockets</anchor-external></li></ul></refs><p><anchor-end xmlns="urn:x-suika-fam-cx:markup:suikawiki:0:9:" a0:anchor="12" xmlns:a0="urn:x-suika-fam-cx:markup:suikawiki:0:9:">[12]</anchor-end> <anchor-internal xmlns="urn:x-suika-fam-cx:markup:suikawiki:0:9:" a0:anchor="11" xmlns:a0="urn:x-suika-fam-cx:markup:suikawiki:0:9:">&gt;&gt;11</anchor-internal> <code>200</code> から <code>205</code> の範囲を返せといっていて、 <code>2xx</code>
でなければエラーと判断するといっている。 (<code>206</code> <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="14" xmlns:a0="urn:x-suika-fam-cx:markup:suikawiki:0:9:">[14]</anchor-end> <anchor-internal xmlns="urn:x-suika-fam-cx:markup:suikawiki:0:9:" a0:anchor="13" xmlns:a0="urn:x-suika-fam-cx:markup:suikawiki:0:9:">&gt;&gt;13</anchor-internal> <code>200</code> か <code>204</code> を返せといっていて、それ以外だとエラーと判断するといっている。</p><p><anchor-end xmlns="urn:x-suika-fam-cx:markup:suikawiki:0:9:" a0:anchor="15" xmlns:a0="urn:x-suika-fam-cx:markup:suikawiki:0:9:">[15]</anchor-end> <anchor-internal xmlns="urn:x-suika-fam-cx:markup:suikawiki:0:9:" a0:anchor="12" xmlns:a0="urn:x-suika-fam-cx:markup:suikawiki:0:9:">&gt;&gt;12</anchor-internal> と <anchor-internal xmlns="urn:x-suika-fam-cx:markup:suikawiki:0:9:" a0:anchor="14" xmlns:a0="urn:x-suika-fam-cx:markup:suikawiki:0:9:">&gt;&gt;14</anchor-internal> で <code>201</code>, <code>202</code>, <code>203</code>, <code>205</code>
の扱いが異なっているが、どういうことか。</p><p><anchor-end xmlns="urn:x-suika-fam-cx:markup:suikawiki:0:9:" a0:anchor="17" xmlns:a0="urn:x-suika-fam-cx:markup:suikawiki:0:9:">[17]</anchor-end> こんなこと書いてる <anchor xmlns="urn:x-suika-fam-cx:markup:suikawiki:0:9:">Vonage</anchor> 自身の <anchor xmlns="urn:x-suika-fam-cx:markup:suikawiki:0:9:">API</anchor> は <code>202</code> を返すんだがw</p></section><section><h1>関連</h1><p><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> <anchor xmlns="urn:x-suika-fam-cx:markup:suikawiki:0:9:">警告符号</anchor>の <code class="HTTP"><anchor xmlns="urn:x-suika-fam-cx:markup:suikawiki:0:9:">2xx</anchor></code> とは関係ありません。</p></section><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="4" xmlns:a0="urn:x-suika-fam-cx:markup:suikawiki:0:9:">[4]</anchor-end> <cite xml:lang="en">Define status, ok status, and use them both · whatwg/fetch@159d43c</cite> (<time>2015-09-08 19:57:32 +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://github.com/whatwg/fetch/commit/159d43c7d55e682d7f3fc3cc800d1c004dd183f6">https://github.com/whatwg/fetch/commit/159d43c7d55e682d7f3fc3cc800d1c004dd183f6</anchor-external></li></ul></refs><figure class="quote"><figcaption><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> <cite xml:lang="en">Webmention</cite>
(<time>2017-01-11 04:06:01 +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://webmention.net/draft/#h-sender-notifies-receiver">https://webmention.net/draft/#h-sender-notifies-receiver</anchor-external></figcaption><blockquote><p>Any 2xx response code must be considered a success.</p></blockquote></figure></section></body></html>