2019-04-21 11:50:48 +08:00

14 lines
35 KiB
HTML
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<div class="body" role="main"><div class="section" id="module-http"><h1><span class="yiyi-st" id="yiyi-10">21.11. <a class="reference internal" href="#module-http" title="http: HTTP status codes and messages"><code class="xref py py-mod docutils literal"><span class="pre">http</span></code></a> — HTTP模块</span></h1><p><span class="yiyi-st" id="yiyi-11"><strong>源码:</strong> <a class="reference external" href="https://hg.python.org/cpython/file/3.5/Lib/http/__init__.py">Lib/http/__init__.py</a></span></p><p><span class="yiyi-st" id="yiyi-12"><a class="reference internal" href="#module-http" title="http: HTTP status codes and messages"><code class="xref py py-mod docutils literal"><span class="pre">http</span></code></a>包用于处理超文本传输协议,包括下面几个模块:</span></p><ul class="simple"><li><span class="yiyi-st" id="yiyi-13"><a class="reference internal" href="http.client.html#module-http.client" title="http.client: HTTP and HTTPS protocol client (requires sockets)."><code class="xref py py-mod docutils literal"><span class="pre">http.client</span></code></a>是低级别的HTTP协议客户端对于高级别的URL开发请参考 <a class="reference internal" href="urllib.request.html#module-urllib.request" title="urllib.request: Extensible library for opening URLs."><code class="xref py py-mod docutils literal"><span class="pre">urllib.request</span></code></a></span></li><li><span class="yiyi-st" id="yiyi-14"><a class="reference internal" href="http.server.html#module-http.server" title="http.server: HTTP server and request handlers."><code class="xref py py-mod docutils literal"><span class="pre">http.server</span></code></a> 包含基于<a class="reference internal" href="socketserver.html#module-socketserver" title="socketserver: A framework for network servers."><code class="xref py py-mod docutils literal"><span class="pre">socketserver</span></code></a>的基本HTTP服务类。</span></li><li><span class="yiyi-st" id="yiyi-15"><a class="reference internal" href="http.cookies.html#module-http.cookies" title="http.cookies: Support for HTTP state management (cookies)."><code class="xref py py-mod docutils literal"><span class="pre">http.cookies</span></code></a> 用于实现cookie状态管理。</span></li><li><span class="yiyi-st" id="yiyi-16"><a class="reference internal" href="http.cookiejar.html#module-http.cookiejar" title="http.cookiejar: Classes for automatic handling of HTTP cookies."><code class="xref py py-mod docutils literal"><span class="pre">http.cookiejar</span></code></a> 提供持久化cookie。</span></li></ul><p><span class="yiyi-st" id="yiyi-17"><a class="reference internal" href="#module-http" title="http: HTTP status codes and messages"><code class="xref py py-mod docutils literal"><span class="pre">http</span></code></a>本身也是一个模块,它通过枚举类 <a class="reference internal" href="#http.HTTPStatus" title="http.HTTPStatus"><code class="xref py py-class docutils literal"><span class="pre">http.HTTPStatus</span></code></a>定义了一系列的HTTP状态码和相关信息。</span></p><dl class="class"><dt id="http.HTTPStatus"><span class="yiyi-st" id="yiyi-18"> <em class="property">class </em><code class="descclassname">http.</code><code class="descname">HTTPStatus</code></span></dt><dd><div class="versionadded"><p><span class="yiyi-st" id="yiyi-19"><span class="versionmodified">版本3.5中的新功能。</span></span></p></div><p><span class="yiyi-st" id="yiyi-20"><a class="reference internal" href="enum.html#enum.IntEnum" title="enum.IntEnum"><code class="xref py py-class docutils literal"><span class="pre">enum.IntEnum</span></code></a>的子类定义了一系列的HTTP状态码、原因短语和长文本描述。</span></p><p><span class="yiyi-st" id="yiyi-21">示例:</span></p><pre><code class="language-python"><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">http</span> <span class="k">import</span> <span class="n">HTTPStatus</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">HTTPStatus</span><span class="o">.</span><span class="n">OK</span>
<span class="go">&lt;HTTPStatus.OK: 200&gt;</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">HTTPStatus</span><span class="o">.</span><span class="n">OK</span> <span class="o">==</span> <span class="mi">200</span>
<span class="go">True</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">http</span><span class="o">.</span><span class="n">HTTPStatus</span><span class="o">.</span><span class="n">OK</span><span class="o">.</span><span class="n">value</span>
<span class="go">200</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">HTTPStatus</span><span class="o">.</span><span class="n">OK</span><span class="o">.</span><span class="n">phrase</span>
<span class="go">'OK'</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">HTTPStatus</span><span class="o">.</span><span class="n">OK</span><span class="o">.</span><span class="n">description</span>
<span class="go">'Request fulfilled, document follows'</span>
<span class="gp">&gt;&gt;&gt; </span><span class="nb">list</span><span class="p">(</span><span class="n">HTTPStatus</span><span class="p">)</span>
<span class="go">[&lt;HTTPStatus.CONTINUE: 100&gt;, &lt;HTTPStatus.SWITCHING_PROTOCOLS: 101&gt;, ...]</span>
</code></pre></dd></dl><div class="section" id="http-status-codes"><h2><span class="yiyi-st" id="yiyi-22">21.11.1. </span><span class="yiyi-st" id="yiyi-23">HTTP状态码</span></h2><p><span class="yiyi-st" id="yiyi-24"><a class="reference internal" href="#http.HTTPStatus" title="http.HTTPStatus"><code class="xref py py-class docutils literal"><span class="pre">http.HTTPStatus</span></code></a> 中支持的状态码列表如下: 都已注册IANA参考<a class="reference external" href="https://www.iana.org/assignments/http-status-codes/http-status-codes.xhtml">IANA-registered</a></span></p><table border="1" class="docutils"><thead valign="bottom"><tr class="row-odd"><th class="head"><span class="yiyi-st" id="yiyi-25"></span></th><th class="head"><span class="yiyi-st" id="yiyi-26">枚举名称</span></th><th class="head"><span class="yiyi-st" id="yiyi-27">细节</span></th></tr></thead><tbody valign="top"><tr class="row-even"><td><span class="yiyi-st" id="yiyi-28"><code class="docutils literal"><span class="pre">100</span></code></span></td><td><span class="yiyi-st" id="yiyi-29"><code class="docutils literal"><span class="pre">CONTINUE</span></code></span></td><td><span class="yiyi-st" id="yiyi-30">HTTP / 1.1 <span class="target" id="index-1"></span> <a class="rfc reference external" href="https://tools.ietf.org/html/rfc7231.html"><strong>RFC 7231</strong></a>第6.2.1节</span></td></tr><tr class="row-odd"><td><span class="yiyi-st" id="yiyi-31"><code class="docutils literal"><span class="pre">101</span></code></span></td><td><span class="yiyi-st" id="yiyi-32"><code class="docutils literal"><span class="pre">SWITCHING_PROTOCOLS</span></code></span></td><td><span class="yiyi-st" id="yiyi-33">HTTP / 1.1 <span class="target" id="index-2"></span> <a class="rfc reference external" href="https://tools.ietf.org/html/rfc7231.html"><strong>RFC 7231</strong></a>第6.2.2节</span></td></tr><tr class="row-even"><td><span class="yiyi-st" id="yiyi-34"><code class="docutils literal"><span class="pre">102</span></code></span></td><td><span class="yiyi-st" id="yiyi-35"><code class="docutils literal"><span class="pre">PROCESSING</span></code></span></td><td><span class="yiyi-st" id="yiyi-36">WebDAV <span class="target" id="index-3"></span> <a class="rfc reference external" href="https://tools.ietf.org/html/rfc2518.html"><strong>RFC 2518</strong></a>第10.1节</span></td></tr><tr class="row-odd"><td><span class="yiyi-st" id="yiyi-37"><code class="docutils literal"><span class="pre">200</span></code></span></td><td><span class="yiyi-st" id="yiyi-38"><code class="docutils literal"><span class="pre">OK</span></code></span></td><td><span class="yiyi-st" id="yiyi-39">HTTP / 1.1 <span class="target" id="index-4"></span> <a class="rfc reference external" href="https://tools.ietf.org/html/rfc7231.html"><strong>RFC 7231</strong></a>第6.3.1节</span></td></tr><tr class="row-even"><td><span class="yiyi-st" id="yiyi-40"><code class="docutils literal"><span class="pre">201</span></code></span></td><td><span class="yiyi-st" id="yiyi-41"><code class="docutils literal"><span class="pre">CREATED</span></code></span></td><td><span class="yiyi-st" id="yiyi-42">HTTP / 1.1 <span class="target" id="index-5"></span> <a class="rfc reference external" href="https://tools.ietf.org/html/rfc7231.html"><strong>RFC 7231</strong></a>第6.3.2节</span></td></tr><tr class="row-odd"><td><span class="yiyi-st" id="yiyi-43"><code class="docutils literal"><span class="pre">202</span></code></span></td><td><span class="yiyi-st" id="yiyi-44"><code class="docutils literal"><span class="pre">ACCEPTED</span></code></span></td><td><span class="yiyi-st" id="yiyi-45">HTTP / 1.1 <span class="target" id="index-6"></span> <a class="rfc reference external" href="https://tools.ietf.org/html/rfc7231.html"><strong>RFC 7231</strong></a>第6.3.3节</span></td></tr><tr class="row-even"><td><span class="yiyi-st" id="yiyi-46"><code class="docutils literal"><span class="pre">203</span></code></span></td><td><span class="yiyi-st" id="yiyi-47"><code class="docutils literal"><span class="pre">NON_AUTHORITATIVE_INFORMATION</span></code></span></td><td><span class="yiyi-st" id="yiyi-48">HTTP / 1.1 <span class="target" id="index-7"></span> <a class="rfc reference external" href="https://tools.ietf.org/html/rfc7231.html"><strong>RFC 7231</strong></a>第6.3.4节</span></td></tr><tr class="row-odd"><td><span class="yiyi-st" id="yiyi-49"><code class="docutils literal"><span class="pre">204</span></code></span></td><td><span class="yiyi-st" id="yiyi-50"><code class="docutils literal"><span class="pre">NO_CONTENT</span></code></span></td><td><span class="yiyi-st" id="yiyi-51">HTTP / 1.1 <span class="target" id="index-8"></span> <a class="rfc reference external" href="https://tools.ietf.org/html/rfc7231.html"><strong>RFC 7231</strong></a>第6.3.5节</span></td></tr><tr class="row-even"><td><span class="yiyi-st" id="yiyi-52"><code class="docutils literal"><span class="pre">205</span></code></span></td><td><span class="yiyi-st" id="yiyi-53"><code class="docutils literal"><span class="pre">RESET_CONTENT</span></code></span></td><td><span class="yiyi-st" id="yiyi-54">HTTP / 1.1 <span class="target" id="index-9"></span> <a class="rfc reference external" href="https://tools.ietf.org/html/rfc7231.html"><strong>RFC 7231</strong></a>第6.3.6节</span></td></tr><tr class="row-odd"><td><span class="yiyi-st" id="yiyi-55"><code class="docutils literal"><span class="pre">206</span></code></span></td><td><span class="yiyi-st" id="yiyi-56"><code class="docutils literal"><span class="pre">PARTIAL_CONTENT</span></code></span></td><td><span class="yiyi-st" id="yiyi-57">HTTP / 1.1 <span class="target" id="index-10"></span> <a class="rfc reference external" href="https://tools.ietf.org/html/rfc7233.html"><strong>RFC 7233</strong></a>第4.1节</span></td></tr><tr class="row-even"><td><span class="yiyi-st" id="yiyi-58"><code class="docutils literal"><span class="pre">207</span></code></span></td><td><span class="yiyi-st" id="yiyi-59"><code class="docutils literal"><span class="pre">MULTI_STATUS</span></code></span></td><td><span class="yiyi-st" id="yiyi-60">WebDAV <span class="target" id="index-11"></span> <a class="rfc reference external" href="https://tools.ietf.org/html/rfc4918.html"><strong>RFC 4918</strong></a>第11.1节</span></td></tr><tr class="row-odd"><td><span class="yiyi-st" id="yiyi-61"><code class="docutils literal"><span class="pre">208</span></code></span></td><td><span class="yiyi-st" id="yiyi-62"><code class="docutils literal"><span class="pre">ALREADY_REPORTED</span></code></span></td><td><span class="yiyi-st" id="yiyi-63">WebDAV绑定扩展<span class="target" id="index-12"></span> <a class="rfc reference external" href="https://tools.ietf.org/html/rfc5842.html"><strong>RFC 5842</strong></a>第7.1节(实验)</span></td></tr><tr class="row-even"><td><span class="yiyi-st" id="yiyi-64"><code class="docutils literal"><span class="pre">226</span></code></span></td><td><span class="yiyi-st" id="yiyi-65"><code class="docutils literal"><span class="pre">IM_USED</span></code></span></td><td><span class="yiyi-st" id="yiyi-66">HTTP中的增量编码<span class="target" id="index-13"></span> <a class="rfc reference external" href="https://tools.ietf.org/html/rfc3229.html"><strong>RFC 3229</strong></a>第10.4.1节</span></td></tr><tr class="row-odd"><td><span class="yiyi-st" id="yiyi-67"><code class="docutils literal"><span class="pre">300</span></code></span></td><td><span class="yiyi-st" id="yiyi-68"><code class="docutils literal"><span class="pre">MULTIPLE_CHOICES</span></code></span></td><td><span class="yiyi-st" id="yiyi-69">HTTP / 1.1 <span class="target" id="index-14"></span> <a class="rfc reference external" href="https://tools.ietf.org/html/rfc7231.html"><strong>RFC 7231</strong></a>第6.4.1节</span></td></tr><tr class="row-even"><td><span class="yiyi-st" id="yiyi-70"><code class="docutils literal"><span class="pre">301</span></code></span></td><td><span class="yiyi-st" id="yiyi-71"><code class="docutils literal"><span class="pre">MOVED_PERMANENTLY</span></code></span></td><td><span class="yiyi-st" id="yiyi-72">HTTP / 1.1 <span class="target" id="index-15"></span> <a class="rfc reference external" href="https://tools.ietf.org/html/rfc7231.html"><strong>RFC 7231</strong></a>第6.4.2节</span></td></tr><tr class="row-odd"><td><span class="yiyi-st" id="yiyi-73"><code class="docutils literal"><span class="pre">302</span></code></span></td><td><span class="yiyi-st" id="yiyi-74"><code class="docutils literal"><span class="pre">FOUND</span></code></span></td><td><span class="yiyi-st" id="yiyi-75">HTTP / 1.1 <span class="target" id="index-16"></span> <a class="rfc reference external" href="https://tools.ietf.org/html/rfc7231.html"><strong>RFC 7231</strong></a>第6.4.3节</span></td></tr><tr class="row-even"><td><span class="yiyi-st" id="yiyi-76"><code class="docutils literal"><span class="pre">303</span></code></span></td><td><span class="yiyi-st" id="yiyi-77"><code class="docutils literal"><span class="pre">SEE_OTHER</span></code></span></td><td><span class="yiyi-st" id="yiyi-78">HTTP / 1.1 <span class="target" id="index-17"></span> <a class="rfc reference external" href="https://tools.ietf.org/html/rfc7231.html"><strong>RFC 7231</strong></a>第6.4.4节</span></td></tr><tr class="row-odd"><td><span class="yiyi-st" id="yiyi-79"><code class="docutils literal"><span class="pre">304</span></code></span></td><td><span class="yiyi-st" id="yiyi-80"><code class="docutils literal"><span class="pre">NOT_MODIFIED</span></code></span></td><td><span class="yiyi-st" id="yiyi-81">HTTP / 1.1 <span class="target" id="index-18"></span> <a class="rfc reference external" href="https://tools.ietf.org/html/rfc7232.html"><strong>RFC 7232</strong></a>第4.1节</span></td></tr><tr class="row-even"><td><span class="yiyi-st" id="yiyi-82"><code class="docutils literal"><span class="pre">305</span></code></span></td><td><span class="yiyi-st" id="yiyi-83"><code class="docutils literal"><span class="pre">USE_PROXY</span></code></span></td><td><span class="yiyi-st" id="yiyi-84">HTTP / 1.1 <span class="target" id="index-19"></span> <a class="rfc reference external" href="https://tools.ietf.org/html/rfc7231.html"><strong>RFC 7231</strong></a>第6.4.5节</span></td></tr><tr class="row-odd"><td><span class="yiyi-st" id="yiyi-85"><code class="docutils literal"><span class="pre">307</span></code></span></td><td><span class="yiyi-st" id="yiyi-86"><code class="docutils literal"><span class="pre">TEMPORARY_REDIRECT</span></code></span></td><td><span class="yiyi-st" id="yiyi-87">HTTP / 1.1 <span class="target" id="index-20"></span> <a class="rfc reference external" href="https://tools.ietf.org/html/rfc7231.html"><strong>RFC 7231</strong></a>第6.4.7节</span></td></tr><tr class="row-even"><td><span class="yiyi-st" id="yiyi-88"><code class="docutils literal"><span class="pre">308</span></code></span></td><td><span class="yiyi-st" id="yiyi-89"><code class="docutils literal"><span class="pre">PERMANENT_REDIRECT</span></code></span></td><td><span class="yiyi-st" id="yiyi-90">永久重定向<span class="target" id="index-21"></span> <a class="rfc reference external" href="https://tools.ietf.org/html/rfc7238.html"><strong>RFC 7238</strong></a>第3节实验</span></td></tr><tr class="row-odd"><td><span class="yiyi-st" id="yiyi-91"><code class="docutils literal"><span class="pre">400</span></code></span></td><td><span class="yiyi-st" id="yiyi-92"><code class="docutils literal"><span class="pre">BAD_REQUEST</span></code></span></td><td><span class="yiyi-st" id="yiyi-93">HTTP / 1.1 <span class="target" id="index-22"></span> <a class="rfc reference external" href="https://tools.ietf.org/html/rfc7231.html"><strong>RFC 7231</strong></a>第6.5.1节</span></td></tr><tr class="row-even"><td><span class="yiyi-st" id="yiyi-94"><code class="docutils literal"><span class="pre">401</span></code></span></td><td><span class="yiyi-st" id="yiyi-95"><code class="docutils literal"><span class="pre">UNAUTHORIZED</span></code></span></td><td><span class="yiyi-st" id="yiyi-96">HTTP / 1.1认证<span class="target" id="index-23"></span> <a class="rfc reference external" href="https://tools.ietf.org/html/rfc7235.html"><strong>RFC 7235</strong></a>第3.1节</span></td></tr><tr class="row-odd"><td><span class="yiyi-st" id="yiyi-97"><code class="docutils literal"><span class="pre">402</span></code></span></td><td><span class="yiyi-st" id="yiyi-98"><code class="docutils literal"><span class="pre">PAYMENT_REQUIRED</span></code></span></td><td><span class="yiyi-st" id="yiyi-99">HTTP / 1.1 <span class="target" id="index-24"></span> <a class="rfc reference external" href="https://tools.ietf.org/html/rfc7231.html"><strong>RFC 7231</strong></a>第6.5.2节</span></td></tr><tr class="row-even"><td><span class="yiyi-st" id="yiyi-100"><code class="docutils literal"><span class="pre">403</span></code></span></td><td><span class="yiyi-st" id="yiyi-101"><code class="docutils literal"><span class="pre">FORBIDDEN</span></code></span></td><td><span class="yiyi-st" id="yiyi-102">HTTP / 1.1 <span class="target" id="index-25"></span> <a class="rfc reference external" href="https://tools.ietf.org/html/rfc7231.html"><strong>RFC 7231</strong></a>第6.5.3节</span></td></tr><tr class="row-odd"><td><span class="yiyi-st" id="yiyi-103"><code class="docutils literal"><span class="pre">404</span></code></span></td><td><span class="yiyi-st" id="yiyi-104"><code class="docutils literal"><span class="pre">NOT_FOUND</span></code></span></td><td><span class="yiyi-st" id="yiyi-105">HTTP / 1.1 <span class="target" id="index-26"></span> <a class="rfc reference external" href="https://tools.ietf.org/html/rfc7231.html"><strong>RFC 7231</strong></a>第6.5.4节</span></td></tr><tr class="row-even"><td><span class="yiyi-st" id="yiyi-106"><code class="docutils literal"><span class="pre">405</span></code></span></td><td><span class="yiyi-st" id="yiyi-107"><code class="docutils literal"><span class="pre">METHOD_NOT_ALLOWED</span></code></span></td><td><span class="yiyi-st" id="yiyi-108">HTTP / 1.1 <span class="target" id="index-27"></span> <a class="rfc reference external" href="https://tools.ietf.org/html/rfc7231.html"><strong>RFC 7231</strong></a>第6.5.5节</span></td></tr><tr class="row-odd"><td><span class="yiyi-st" id="yiyi-109"><code class="docutils literal"><span class="pre">406</span></code></span></td><td><span class="yiyi-st" id="yiyi-110"><code class="docutils literal"><span class="pre">NOT_ACCEPTABLE</span></code></span></td><td><span class="yiyi-st" id="yiyi-111">HTTP / 1.1 <span class="target" id="index-28"></span> <a class="rfc reference external" href="https://tools.ietf.org/html/rfc7231.html"><strong>RFC 7231</strong></a>第6.5.6节</span></td></tr><tr class="row-even"><td><span class="yiyi-st" id="yiyi-112"><code class="docutils literal"><span class="pre">407</span></code></span></td><td><span class="yiyi-st" id="yiyi-113"><code class="docutils literal"><span class="pre">PROXY_AUTHENTICATION_REQUIRED</span></code></span></td><td><span class="yiyi-st" id="yiyi-114">HTTP / 1.1认证<span class="target" id="index-29"></span> <a class="rfc reference external" href="https://tools.ietf.org/html/rfc7235.html"><strong>RFC 7235</strong></a>第3.2节</span></td></tr><tr class="row-odd"><td><span class="yiyi-st" id="yiyi-115"><code class="docutils literal"><span class="pre">408</span></code></span></td><td><span class="yiyi-st" id="yiyi-116"><code class="docutils literal"><span class="pre">REQUEST_TIMEOUT</span></code></span></td><td><span class="yiyi-st" id="yiyi-117">HTTP / 1.1 <span class="target" id="index-30"></span> <a class="rfc reference external" href="https://tools.ietf.org/html/rfc7231.html"><strong>RFC 7231</strong></a>第6.5.7节</span></td></tr><tr class="row-even"><td><span class="yiyi-st" id="yiyi-118"><code class="docutils literal"><span class="pre">409</span></code></span></td><td><span class="yiyi-st" id="yiyi-119"><code class="docutils literal"><span class="pre">CONFLICT</span></code></span></td><td><span class="yiyi-st" id="yiyi-120">HTTP / 1.1 <span class="target" id="index-31"></span> <a class="rfc reference external" href="https://tools.ietf.org/html/rfc7231.html"><strong>RFC 7231</strong></a>第6.5.8节</span></td></tr><tr class="row-odd"><td><span class="yiyi-st" id="yiyi-121"><code class="docutils literal"><span class="pre">410</span></code></span></td><td><span class="yiyi-st" id="yiyi-122"><code class="docutils literal"><span class="pre">GONE</span></code></span></td><td><span class="yiyi-st" id="yiyi-123">HTTP / 1.1 <span class="target" id="index-32"></span> <a class="rfc reference external" href="https://tools.ietf.org/html/rfc7231.html"><strong>RFC 7231</strong></a>第6.5.9节</span></td></tr><tr class="row-even"><td><span class="yiyi-st" id="yiyi-124"><code class="docutils literal"><span class="pre">411</span></code></span></td><td><span class="yiyi-st" id="yiyi-125"><code class="docutils literal"><span class="pre">LENGTH_REQUIRED</span></code></span></td><td><span class="yiyi-st" id="yiyi-126">HTTP / 1.1 <span class="target" id="index-33"></span> <a class="rfc reference external" href="https://tools.ietf.org/html/rfc7231.html"><strong>RFC 7231</strong></a>第6.5.10节</span></td></tr><tr class="row-odd"><td><span class="yiyi-st" id="yiyi-127"><code class="docutils literal"><span class="pre">412</span></code></span></td><td><span class="yiyi-st" id="yiyi-128"><code class="docutils literal"><span class="pre">PRECONDITION_FAILED</span></code></span></td><td><span class="yiyi-st" id="yiyi-129">HTTP / 1.1 <span class="target" id="index-34"></span> <a class="rfc reference external" href="https://tools.ietf.org/html/rfc7232.html"><strong>RFC 7232</strong></a>第4.2节</span></td></tr><tr class="row-even"><td><span class="yiyi-st" id="yiyi-130"><code class="docutils literal"><span class="pre">413</span></code></span></td><td><span class="yiyi-st" id="yiyi-131"><code class="docutils literal"><span class="pre">REQUEST_ENTITY_TOO_LARGE</span></code></span></td><td><span class="yiyi-st" id="yiyi-132">HTTP / 1.1 <span class="target" id="index-35"></span> <a class="rfc reference external" href="https://tools.ietf.org/html/rfc7231.html"><strong>RFC 7231</strong></a>第6.5.11节</span></td></tr><tr class="row-odd"><td><span class="yiyi-st" id="yiyi-133"><code class="docutils literal"><span class="pre">414</span></code></span></td><td><span class="yiyi-st" id="yiyi-134"><code class="docutils literal"><span class="pre">REQUEST_URI_TOO_LONG</span></code></span></td><td><span class="yiyi-st" id="yiyi-135">HTTP / 1.1 <span class="target" id="index-36"></span> <a class="rfc reference external" href="https://tools.ietf.org/html/rfc7231.html"><strong>RFC 7231</strong></a>第6.5.12节</span></td></tr><tr class="row-even"><td><span class="yiyi-st" id="yiyi-136"><code class="docutils literal"><span class="pre">415</span></code></span></td><td><span class="yiyi-st" id="yiyi-137"><code class="docutils literal"><span class="pre">UNSUPPORTED_MEDIA_TYPE</span></code></span></td><td><span class="yiyi-st" id="yiyi-138">HTTP / 1.1 <span class="target" id="index-37"></span> <a class="rfc reference external" href="https://tools.ietf.org/html/rfc7231.html"><strong>RFC 7231</strong></a>第6.5.13节</span></td></tr><tr class="row-odd"><td><span class="yiyi-st" id="yiyi-139"><code class="docutils literal"><span class="pre">416</span></code></span></td><td><span class="yiyi-st" id="yiyi-140"><code class="docutils literal"><span class="pre">REQUEST_RANGE_NOT_SATISFIABLE</span></code></span></td><td><span class="yiyi-st" id="yiyi-141">HTTP / 1.1范围请求<span class="target" id="index-38"></span> <a class="rfc reference external" href="https://tools.ietf.org/html/rfc7233.html"><strong>RFC 7233</strong></a>第4.4节</span></td></tr><tr class="row-even"><td><span class="yiyi-st" id="yiyi-142"><code class="docutils literal"><span class="pre">417</span></code></span></td><td><span class="yiyi-st" id="yiyi-143"><code class="docutils literal"><span class="pre">EXPECTATION_FAILED</span></code></span></td><td><span class="yiyi-st" id="yiyi-144">HTTP / 1.1 <span class="target" id="index-39"></span> <a class="rfc reference external" href="https://tools.ietf.org/html/rfc7231.html"><strong>RFC 7231</strong></a>第6.5.14节</span></td></tr><tr class="row-odd"><td><span class="yiyi-st" id="yiyi-145"><code class="docutils literal"><span class="pre">422</span></code></span></td><td><span class="yiyi-st" id="yiyi-146"><code class="docutils literal"><span class="pre">UNPROCESSABLE_ENTITY</span></code></span></td><td><span class="yiyi-st" id="yiyi-147">WebDAV <span class="target" id="index-40"></span> <a class="rfc reference external" href="https://tools.ietf.org/html/rfc4918.html"><strong>RFC 4918</strong></a>第11.2节</span></td></tr><tr class="row-even"><td><span class="yiyi-st" id="yiyi-148"><code class="docutils literal"><span class="pre">423</span></code></span></td><td><span class="yiyi-st" id="yiyi-149"><code class="docutils literal"><span class="pre">LOCKED</span></code></span></td><td><span class="yiyi-st" id="yiyi-150">WebDAV <span class="target" id="index-41"></span> <a class="rfc reference external" href="https://tools.ietf.org/html/rfc4918.html"><strong>RFC 4918</strong></a>第11.3节</span></td></tr><tr class="row-odd"><td><span class="yiyi-st" id="yiyi-151"><code class="docutils literal"><span class="pre">424</span></code></span></td><td><span class="yiyi-st" id="yiyi-152"><code class="docutils literal"><span class="pre">FAILED_DEPENDENCY</span></code></span></td><td><span class="yiyi-st" id="yiyi-153">WebDAV <span class="target" id="index-42"></span> <a class="rfc reference external" href="https://tools.ietf.org/html/rfc4918.html"><strong>RFC 4918</strong></a>第11.4节</span></td></tr><tr class="row-even"><td><span class="yiyi-st" id="yiyi-154"><code class="docutils literal"><span class="pre">426</span></code></span></td><td><span class="yiyi-st" id="yiyi-155"><code class="docutils literal"><span class="pre">UPGRADE_REQUIRED</span></code></span></td><td><span class="yiyi-st" id="yiyi-156">HTTP / 1.1 <span class="target" id="index-43"></span> <a class="rfc reference external" href="https://tools.ietf.org/html/rfc7231.html"><strong>RFC 7231</strong></a>第6.5.15节</span></td></tr><tr class="row-odd"><td><span class="yiyi-st" id="yiyi-157"><code class="docutils literal"><span class="pre">428</span></code></span></td><td><span class="yiyi-st" id="yiyi-158"><code class="docutils literal"><span class="pre">PRECONDITION_REQUIRED</span></code></span></td><td><span class="yiyi-st" id="yiyi-159">其他HTTP状态码<span class="target" id="index-44"></span> <a class="rfc reference external" href="https://tools.ietf.org/html/rfc6585.html"><strong>RFC 6585</strong></a></span></td></tr><tr class="row-even"><td><span class="yiyi-st" id="yiyi-160"><code class="docutils literal"><span class="pre">429</span></code></span></td><td><span class="yiyi-st" id="yiyi-161"><code class="docutils literal"><span class="pre">TOO_MANY_REQUESTS</span></code></span></td><td><span class="yiyi-st" id="yiyi-162">其他HTTP状态码<span class="target" id="index-45"></span> <a class="rfc reference external" href="https://tools.ietf.org/html/rfc6585.html"><strong>RFC 6585</strong></a></span></td></tr><tr class="row-odd"><td><span class="yiyi-st" id="yiyi-163"><code class="docutils literal"><span class="pre">431</span></code></span></td><td><span class="yiyi-st" id="yiyi-164"><code class="docutils literal"><span class="pre">REQUEST_HEADER_FIELDS_TOO_LARGE</span></code></span></td><td><span class="yiyi-st" id="yiyi-165">其他HTTP状态码<span class="target" id="index-46"></span> <a class="rfc reference external" href="https://tools.ietf.org/html/rfc6585.html"><strong>RFC 6585</strong></a></span></td></tr><tr class="row-even"><td><span class="yiyi-st" id="yiyi-166"><code class="docutils literal"><span class="pre">500</span></code></span></td><td><span class="yiyi-st" id="yiyi-167"><code class="docutils literal"><span class="pre">INTERNAL_SERVER_ERROR</span></code></span></td><td><span class="yiyi-st" id="yiyi-168">HTTP / 1.1 <span class="target" id="index-47"></span> <a class="rfc reference external" href="https://tools.ietf.org/html/rfc7231.html"><strong>RFC 7231</strong></a>第6.6.1节</span></td></tr><tr class="row-odd"><td><span class="yiyi-st" id="yiyi-169"><code class="docutils literal"><span class="pre">501</span></code></span></td><td><span class="yiyi-st" id="yiyi-170"><code class="docutils literal"><span class="pre">NOT_IMPLEMENTED</span></code></span></td><td><span class="yiyi-st" id="yiyi-171">HTTP / 1.1 <span class="target" id="index-48"></span> <a class="rfc reference external" href="https://tools.ietf.org/html/rfc7231.html"><strong>RFC 7231</strong></a>第6.6.2节</span></td></tr><tr class="row-even"><td><span class="yiyi-st" id="yiyi-172"><code class="docutils literal"><span class="pre">502</span></code></span></td><td><span class="yiyi-st" id="yiyi-173"><code class="docutils literal"><span class="pre">BAD_GATEWAY</span></code></span></td><td><span class="yiyi-st" id="yiyi-174">HTTP / 1.1 <span class="target" id="index-49"></span> <a class="rfc reference external" href="https://tools.ietf.org/html/rfc7231.html"><strong>RFC 7231</strong></a>第6.6.3节</span></td></tr><tr class="row-odd"><td><span class="yiyi-st" id="yiyi-175"><code class="docutils literal"><span class="pre">503</span></code></span></td><td><span class="yiyi-st" id="yiyi-176"><code class="docutils literal"><span class="pre">SERVICE_UNAVAILABLE</span></code></span></td><td><span class="yiyi-st" id="yiyi-177">HTTP / 1.1 <span class="target" id="index-50"></span> <a class="rfc reference external" href="https://tools.ietf.org/html/rfc7231.html"><strong>RFC 7231</strong></a>第6.6.4节</span></td></tr><tr class="row-even"><td><span class="yiyi-st" id="yiyi-178"><code class="docutils literal"><span class="pre">504</span></code></span></td><td><span class="yiyi-st" id="yiyi-179"><code class="docutils literal"><span class="pre">GATEWAY_TIMEOUT</span></code></span></td><td><span class="yiyi-st" id="yiyi-180">HTTP / 1.1 <span class="target" id="index-51"></span> <a class="rfc reference external" href="https://tools.ietf.org/html/rfc7231.html"><strong>RFC 7231</strong></a>第6.6.5节</span></td></tr><tr class="row-odd"><td><span class="yiyi-st" id="yiyi-181"><code class="docutils literal"><span class="pre">505</span></code></span></td><td><span class="yiyi-st" id="yiyi-182"><code class="docutils literal"><span class="pre">HTTP_VERSION_NOT_SUPPORTED</span></code></span></td><td><span class="yiyi-st" id="yiyi-183">HTTP / 1.1 <span class="target" id="index-52"></span> <a class="rfc reference external" href="https://tools.ietf.org/html/rfc7231.html"><strong>RFC 7231</strong></a>第6.6.6节</span></td></tr><tr class="row-even"><td><span class="yiyi-st" id="yiyi-184"><code class="docutils literal"><span class="pre">506</span></code></span></td><td><span class="yiyi-st" id="yiyi-185"><code class="docutils literal"><span class="pre">VARIANT_ALSO_NEGOTIATES</span></code></span></td><td><span class="yiyi-st" id="yiyi-186">HTTP中的透明内容协商<span class="target" id="index-53"></span> <a class="rfc reference external" href="https://tools.ietf.org/html/rfc2295.html"><strong>RFC 2295</strong></a>第8.1节(实验)</span></td></tr><tr class="row-odd"><td><span class="yiyi-st" id="yiyi-187"><code class="docutils literal"><span class="pre">507</span></code></span></td><td><span class="yiyi-st" id="yiyi-188"><code class="docutils literal"><span class="pre">INSUFFICIENT_STORAGE</span></code></span></td><td><span class="yiyi-st" id="yiyi-189">WebDAV <span class="target" id="index-54"></span> <a class="rfc reference external" href="https://tools.ietf.org/html/rfc4918.html"><strong>RFC 4918</strong></a>第11.5节</span></td></tr><tr class="row-even"><td><span class="yiyi-st" id="yiyi-190"><code class="docutils literal"><span class="pre">508</span></code></span></td><td><span class="yiyi-st" id="yiyi-191"><code class="docutils literal"><span class="pre">LOOP_DETECTED</span></code></span></td><td><span class="yiyi-st" id="yiyi-192">WebDAV绑定扩展<span class="target" id="index-55"></span> <a class="rfc reference external" href="https://tools.ietf.org/html/rfc5842.html"><strong>RFC 5842</strong></a>第7.2节(实验)</span></td></tr><tr class="row-odd"><td><span class="yiyi-st" id="yiyi-193"><code class="docutils literal"><span class="pre">510</span></code></span></td><td><span class="yiyi-st" id="yiyi-194"><code class="docutils literal"><span class="pre">NOT_EXTENDED</span></code></span></td><td><span class="yiyi-st" id="yiyi-195">HTTP扩展框架<span class="target" id="index-56"></span> <a class="rfc reference external" href="https://tools.ietf.org/html/rfc2774.html"><strong>RFC 2774</strong></a>第7节实验</span></td></tr><tr class="row-even"><td><span class="yiyi-st" id="yiyi-196"><code class="docutils literal"><span class="pre">511</span></code></span></td><td><span class="yiyi-st" id="yiyi-197"><code class="docutils literal"><span class="pre">NETWORK_AUTHENTICATION_REQUIRED</span></code></span></td><td><span class="yiyi-st" id="yiyi-198">其他HTTP状态代码<span class="target" id="index-57"></span> <a class="rfc reference external" href="https://tools.ietf.org/html/rfc6585.html"><strong>RFC 6585</strong></a>第6节</span></td></tr></tbody></table><p><span class="yiyi-st" id="yiyi-199">为了保持向下兼容性,枚举值也以常量形式存在于<a class="reference internal" href="http.client.html#module-http.client" title="http.client: HTTP and HTTPS protocol client (requires sockets)."><code class="xref py py-mod docutils literal"><span class="pre">http.client</span></code></a>模块中。</span><span class="yiyi-st" id="yiyi-200">枚举名称就等于常量的名称。</span><span class="yiyi-st" id="yiyi-201">比如:<code class="docutils literal"><span class="pre">http.HTTPStatus.OK</span></code>就等于 <code class="docutils literal"><span class="pre">http.client.OK</span></code></span></p></div></div></div>