567 lines
36 KiB
HTML
567 lines
36 KiB
HTML
|
||
<!DOCTYPE html>
|
||
|
||
<html xmlns="http://www.w3.org/1999/xhtml" lang="zh_CN">
|
||
<head>
|
||
<meta charset="utf-8" /><meta name="generator" content="Docutils 0.17.1: http://docutils.sourceforge.net/" />
|
||
|
||
<title>http --- HTTP 模块 — Python 3.8.20 文档</title><meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||
|
||
<link rel="stylesheet" href="../_static/pydoctheme.css" type="text/css" />
|
||
<link rel="stylesheet" href="../_static/pygments.css" type="text/css" />
|
||
|
||
<script id="documentation_options" data-url_root="../" src="../_static/documentation_options.js"></script>
|
||
<script src="../_static/jquery.js"></script>
|
||
<script src="../_static/underscore.js"></script>
|
||
<script src="../_static/doctools.js"></script>
|
||
<script src="../_static/language_data.js"></script>
|
||
<script src="../_static/translations.js"></script>
|
||
|
||
<script src="../_static/sidebar.js"></script>
|
||
|
||
<link rel="search" type="application/opensearchdescription+xml"
|
||
title="在 Python 3.8.20 文档 中搜索"
|
||
href="../_static/opensearch.xml"/>
|
||
<link rel="author" title="关于这些文档" href="../about.html" />
|
||
<link rel="index" title="索引" href="../genindex.html" />
|
||
<link rel="search" title="搜索" href="../search.html" />
|
||
<link rel="copyright" title="版权所有" href="../copyright.html" />
|
||
<link rel="next" title="http.client --- HTTP 协议客户端" href="http.client.html" />
|
||
<link rel="prev" title="urllib.robotparser --- robots.txt 语法分析程序" href="urllib.robotparser.html" />
|
||
<link rel="canonical" href="https://docs.python.org/3/library/http.html" />
|
||
|
||
|
||
|
||
|
||
|
||
<style>
|
||
@media only screen {
|
||
table.full-width-table {
|
||
width: 100%;
|
||
}
|
||
}
|
||
</style>
|
||
<link rel="shortcut icon" type="image/png" href="../_static/py.svg" />
|
||
<script type="text/javascript" src="../_static/copybutton.js"></script>
|
||
<script type="text/javascript" src="../_static/menu.js"></script>
|
||
|
||
</head>
|
||
<body>
|
||
<div class="mobile-nav">
|
||
<input type="checkbox" id="menuToggler" class="toggler__input" aria-controls="navigation"
|
||
aria-pressed="false" aria-expanded="false" role="button" aria-label="Menu" />
|
||
<label for="menuToggler" class="toggler__label">
|
||
<span></span>
|
||
</label>
|
||
<nav class="nav-content" role="navigation">
|
||
<a href="https://www.python.org/" class="nav-logo">
|
||
<img src="../_static/py.svg" alt="Logo"/>
|
||
</a>
|
||
<div class="version_switcher_placeholder"></div>
|
||
<form role="search" class="search" action="../search.html" method="get">
|
||
<svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" class="search-icon">
|
||
<path fill-rule="nonzero"
|
||
d="M15.5 14h-.79l-.28-.27a6.5 6.5 0 001.48-5.34c-.47-2.78-2.79-5-5.59-5.34a6.505 6.505 0 00-7.27 7.27c.34 2.8 2.56 5.12 5.34 5.59a6.5 6.5 0 005.34-1.48l.27.28v.79l4.25 4.25c.41.41 1.08.41 1.49 0 .41-.41.41-1.08 0-1.49L15.5 14zm-6 0C7.01 14 5 11.99 5 9.5S7.01 5 9.5 5 14 7.01 14 9.5 11.99 14 9.5 14z" fill="#444"></path>
|
||
</svg>
|
||
<input type="text" name="q" aria-label="快速搜索"/>
|
||
<input type="submit" value="转向"/>
|
||
</form>
|
||
</nav>
|
||
<div class="menu-wrapper">
|
||
<nav class="menu" role="navigation" aria-label="main navigation">
|
||
<div class="language_switcher_placeholder"></div>
|
||
<h3><a href="../contents.html">目录</a></h3>
|
||
<ul>
|
||
<li><a class="reference internal" href="#"><code class="xref py py-mod docutils literal notranslate"><span class="pre">http</span></code> --- HTTP 模块</a><ul>
|
||
<li><a class="reference internal" href="#http-status-codes">HTTP 状态码</a></li>
|
||
</ul>
|
||
</li>
|
||
</ul>
|
||
|
||
<h4>上一个主题</h4>
|
||
<p class="topless"><a href="urllib.robotparser.html"
|
||
title="上一章"><code class="xref py py-mod docutils literal notranslate"><span class="pre">urllib.robotparser</span></code> --- robots.txt 语法分析程序</a></p>
|
||
<h4>下一个主题</h4>
|
||
<p class="topless"><a href="http.client.html"
|
||
title="下一章"><code class="xref py py-mod docutils literal notranslate"><span class="pre">http.client</span></code> --- HTTP 协议客户端</a></p>
|
||
<div role="note" aria-label="source link">
|
||
<h3>本页</h3>
|
||
<ul class="this-page-menu">
|
||
<li><a href="../bugs.html">报告 Bug</a></li>
|
||
<li>
|
||
<a href="https://github.com/python/cpython/blob/3.8/Doc/library/http.rst"
|
||
rel="nofollow">显示源代码
|
||
</a>
|
||
</li>
|
||
</ul>
|
||
</div>
|
||
</nav>
|
||
</div>
|
||
</div>
|
||
|
||
<div id="outdated-warning" style="padding: .5em; text-align: center; background-color: #FFBABA; color: #6A0E0E;">
|
||
这个文档所针对的是一个已不再受支持的 Python 旧版本。
|
||
你应当升级版本,并阅读
|
||
<a href="/3/library/http.html"> Python 当前稳定版本的文档</a>.
|
||
</div>
|
||
|
||
<div class="related" role="navigation" aria-label="related navigation">
|
||
<h3>导航</h3>
|
||
<ul>
|
||
<li class="right" style="margin-right: 10px">
|
||
<a href="../genindex.html" title="总目录"
|
||
accesskey="I">索引</a></li>
|
||
<li class="right" >
|
||
<a href="../py-modindex.html" title="Python 模块索引"
|
||
>模块</a> |</li>
|
||
<li class="right" >
|
||
<a href="http.client.html" title="http.client --- HTTP 协议客户端"
|
||
accesskey="N">下一页</a> |</li>
|
||
<li class="right" >
|
||
<a href="urllib.robotparser.html" title="urllib.robotparser --- robots.txt 语法分析程序"
|
||
accesskey="P">上一页</a> |</li>
|
||
|
||
<li><img src="../_static/py.svg" alt="python logo" style="vertical-align: middle; margin-top: -1px"/></li>
|
||
<li><a href="https://www.python.org/">Python</a> »</li>
|
||
<li class="switchers">
|
||
<div class="language_switcher_placeholder"></div>
|
||
<div class="version_switcher_placeholder"></div>
|
||
</li>
|
||
<li>
|
||
|
||
</li>
|
||
<li id="cpython-language-and-version">
|
||
<a href="../index.html">3.8.20 Documentation</a> »
|
||
</li>
|
||
|
||
<li class="nav-item nav-item-1"><a href="index.html" >Python 标准库</a> »</li>
|
||
<li class="nav-item nav-item-2"><a href="internet.html" accesskey="U">互联网协议和支持</a> »</li>
|
||
<li class="right">
|
||
|
||
|
||
<div class="inline-search" role="search">
|
||
<form class="inline-search" action="../search.html" method="get">
|
||
<input placeholder="快速搜索" aria-label="快速搜索" type="text" name="q" />
|
||
<input type="submit" value="转向" />
|
||
<input type="hidden" name="check_keywords" value="yes" />
|
||
<input type="hidden" name="area" value="default" />
|
||
</form>
|
||
</div>
|
||
|
|
||
</li>
|
||
|
||
</ul>
|
||
</div>
|
||
|
||
<div class="document">
|
||
<div class="documentwrapper">
|
||
<div class="bodywrapper">
|
||
<div class="body" role="main">
|
||
|
||
<section id="module-http">
|
||
<span id="http-http-modules"></span><h1><a class="reference internal" href="#module-http" title="http: HTTP status codes and messages"><code class="xref py py-mod docutils literal notranslate"><span class="pre">http</span></code></a> --- HTTP 模块<a class="headerlink" href="#module-http" title="永久链接至标题">¶</a></h1>
|
||
<p><strong>源代码:</strong> <a class="reference external" href="https://github.com/python/cpython/tree/3.8/Lib/http/__init__.py">Lib/http/__init__.py</a></p>
|
||
<hr class="docutils" id="index-0" />
|
||
<p><a class="reference internal" href="#module-http" title="http: HTTP status codes and messages"><code class="xref py py-mod docutils literal notranslate"><span class="pre">http</span></code></a> 是一个包,它收集了多个用于处理超文本传输协议的模块:</p>
|
||
<ul class="simple">
|
||
<li><p><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 notranslate"><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 notranslate"><span class="pre">urllib.request</span></code></a></p></li>
|
||
<li><p><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 notranslate"><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 notranslate"><span class="pre">socketserver</span></code></a> 的基本 HTTP 服务类</p></li>
|
||
<li><p><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 notranslate"><span class="pre">http.cookies</span></code></a> 包含一些有用来实现通过 cookies 进行状态管理的工具</p></li>
|
||
<li><p><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 notranslate"><span class="pre">http.cookiejar</span></code></a> 提供了 cookies 的持久化</p></li>
|
||
</ul>
|
||
<p><a class="reference internal" href="#module-http" title="http: HTTP status codes and messages"><code class="xref py py-mod docutils literal notranslate"><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 notranslate"><span class="pre">http.HTTPStatus</span></code></a> 枚举定义了一些 HTTP 状态码以及相关联消息的模块</p>
|
||
<dl class="class">
|
||
<dt id="http.HTTPStatus">
|
||
<em class="property">class </em><code class="sig-prename descclassname">http.</code><code class="sig-name descname">HTTPStatus</code><a class="headerlink" href="#http.HTTPStatus" title="永久链接至目标">¶</a></dt>
|
||
<dd><div class="versionadded">
|
||
<p><span class="versionmodified added">3.5 新版功能.</span></p>
|
||
</div>
|
||
<p><a class="reference internal" href="enum.html#enum.IntEnum" title="enum.IntEnum"><code class="xref py py-class docutils literal notranslate"><span class="pre">enum.IntEnum</span></code></a> 的子类,它定义了组 HTTP 状态码,原理短语以及用英语书写的长描述文本。</p>
|
||
<p>用法:</p>
|
||
<div class="highlight-python3 notranslate"><div class="highlight"><pre><span></span><span class="gp">>>> </span><span class="kn">from</span> <span class="nn">http</span> <span class="kn">import</span> <span class="n">HTTPStatus</span>
|
||
<span class="gp">>>> </span><span class="n">HTTPStatus</span><span class="o">.</span><span class="n">OK</span>
|
||
<span class="go"><HTTPStatus.OK: 200></span>
|
||
<span class="gp">>>> </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">>>> </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">>>> </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">>>> </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">>>> </span><span class="nb">list</span><span class="p">(</span><span class="n">HTTPStatus</span><span class="p">)</span>
|
||
<span class="go">[<HTTPStatus.CONTINUE: 100>, <HTTPStatus.SWITCHING_PROTOCOLS: 101>, ...]</span>
|
||
</pre></div>
|
||
</div>
|
||
</dd></dl>
|
||
|
||
<section id="http-status-codes">
|
||
<span id="id1"></span><h2>HTTP 状态码<a class="headerlink" href="#http-status-codes" title="永久链接至标题">¶</a></h2>
|
||
<p>已支持并且已在 <a class="reference internal" href="#http.HTTPStatus" title="http.HTTPStatus"><code class="xref py py-class docutils literal notranslate"><span class="pre">http.HTTPStatus</span></code></a> <a class="reference external" href="https://www.iana.org/assignments/http-status-codes/http-status-codes.xhtml">IANA 注册</a> 的状态码有:</p>
|
||
<table class="docutils align-default">
|
||
<colgroup>
|
||
<col style="width: 6%" />
|
||
<col style="width: 29%" />
|
||
<col style="width: 65%" />
|
||
</colgroup>
|
||
<thead>
|
||
<tr class="row-odd"><th class="head"><p>双字母代码</p></th>
|
||
<th class="head"><p>映射名</p></th>
|
||
<th class="head"><p>详情</p></th>
|
||
</tr>
|
||
</thead>
|
||
<tbody>
|
||
<tr class="row-even"><td><p><code class="docutils literal notranslate"><span class="pre">100</span></code></p></td>
|
||
<td><p><code class="docutils literal notranslate"><span class="pre">CONTINUE</span></code>:继续</p></td>
|
||
<td><p>HTTP/1.1 <span class="target" id="index-67"></span><a class="rfc reference external" href="https://tools.ietf.org/html/rfc7231.html"><strong>RFC 7231</strong></a>, 6.2.1 节</p></td>
|
||
</tr>
|
||
<tr class="row-odd"><td><p><code class="docutils literal notranslate"><span class="pre">101</span></code></p></td>
|
||
<td><p><code class="docutils literal notranslate"><span class="pre">SWITCHING_PROTOCOLS</span></code></p></td>
|
||
<td><p>HTTP/1.1 RFC 7231, 6.2.2 节</p></td>
|
||
</tr>
|
||
<tr class="row-even"><td><p><code class="docutils literal notranslate"><span class="pre">102</span></code></p></td>
|
||
<td><p><code class="docutils literal notranslate"><span class="pre">PROCESSING</span></code></p></td>
|
||
<td><p>WebDAV RFC 2518, 10.1 节</p></td>
|
||
</tr>
|
||
<tr class="row-odd"><td><p><code class="docutils literal notranslate"><span class="pre">200</span></code></p></td>
|
||
<td><p><code class="docutils literal notranslate"><span class="pre">OK</span></code></p></td>
|
||
<td><p>HTTP/1.1 RFC 7231, 6.3.1 节</p></td>
|
||
</tr>
|
||
<tr class="row-even"><td><p><code class="docutils literal notranslate"><span class="pre">201</span></code></p></td>
|
||
<td><p><code class="docutils literal notranslate"><span class="pre">CREATED</span></code></p></td>
|
||
<td><p>HTTP/1.1 RFC 7231, 6.3.2 节</p></td>
|
||
</tr>
|
||
<tr class="row-odd"><td><p><code class="docutils literal notranslate"><span class="pre">202</span></code></p></td>
|
||
<td><p><code class="docutils literal notranslate"><span class="pre">ACCEPTED</span></code></p></td>
|
||
<td><p>HTTP/1.1 RFC 7231, 6.3.3 节</p></td>
|
||
</tr>
|
||
<tr class="row-even"><td><p><code class="docutils literal notranslate"><span class="pre">203</span></code></p></td>
|
||
<td><p><code class="docutils literal notranslate"><span class="pre">NON_AUTHORITATIVE_INFORMATION</span></code></p></td>
|
||
<td><p>HTTP/1.1 RFC 7231, 6.3.4 节</p></td>
|
||
</tr>
|
||
<tr class="row-odd"><td><p><code class="docutils literal notranslate"><span class="pre">204</span></code></p></td>
|
||
<td><p><code class="docutils literal notranslate"><span class="pre">NO_CONTENT</span></code>: 没有内容</p></td>
|
||
<td><p>HTTP/1.1 RFC 7231, 6.3.5 节</p></td>
|
||
</tr>
|
||
<tr class="row-even"><td><p><code class="docutils literal notranslate"><span class="pre">205</span></code></p></td>
|
||
<td><p><code class="docutils literal notranslate"><span class="pre">RESET_CONTENT</span></code></p></td>
|
||
<td><p>HTTP/1.1 RFC 7231, 6.3.6 节</p></td>
|
||
</tr>
|
||
<tr class="row-odd"><td><p><code class="docutils literal notranslate"><span class="pre">206</span></code></p></td>
|
||
<td><p><code class="docutils literal notranslate"><span class="pre">PARTIAL_CONTENT</span></code></p></td>
|
||
<td><p>HTTP/1.1 RFC 7233, 4.1 节</p></td>
|
||
</tr>
|
||
<tr class="row-even"><td><p><code class="docutils literal notranslate"><span class="pre">207</span></code></p></td>
|
||
<td><p><code class="docutils literal notranslate"><span class="pre">MULTI_STATUS</span></code></p></td>
|
||
<td><p>WebDAV RFC 4918, 11.1 节</p></td>
|
||
</tr>
|
||
<tr class="row-odd"><td><p><code class="docutils literal notranslate"><span class="pre">208</span></code></p></td>
|
||
<td><p><code class="docutils literal notranslate"><span class="pre">ALREADY_REPORTED</span></code></p></td>
|
||
<td><p>WebDAV Binding Extensions RFC 5842, 7.1 节(实验性)</p></td>
|
||
</tr>
|
||
<tr class="row-even"><td><p><code class="docutils literal notranslate"><span class="pre">226</span></code></p></td>
|
||
<td><p><code class="docutils literal notranslate"><span class="pre">IM_USED</span></code></p></td>
|
||
<td><p>Delta Encoding in HTTP RFC 3229, 10.4.1 节</p></td>
|
||
</tr>
|
||
<tr class="row-odd"><td><p><code class="docutils literal notranslate"><span class="pre">300</span></code></p></td>
|
||
<td><p><code class="docutils literal notranslate"><span class="pre">MULTIPLE_CHOICES</span></code>:有多种资源可选择</p></td>
|
||
<td><p>HTTP/1.1 RFC 7231, 6.4.1 节</p></td>
|
||
</tr>
|
||
<tr class="row-even"><td><p><code class="docutils literal notranslate"><span class="pre">301</span></code></p></td>
|
||
<td><p><code class="docutils literal notranslate"><span class="pre">MOVED_PERMANENTLY</span></code>:永久移动</p></td>
|
||
<td><p>HTTP/1.1 RFC 7231, 6.4.2 节</p></td>
|
||
</tr>
|
||
<tr class="row-odd"><td><p><code class="docutils literal notranslate"><span class="pre">302</span></code></p></td>
|
||
<td><p><code class="docutils literal notranslate"><span class="pre">FOUND</span></code>:临时移动</p></td>
|
||
<td><p>HTTP/1.1 RFC 7231, 6.4.3 节</p></td>
|
||
</tr>
|
||
<tr class="row-even"><td><p><code class="docutils literal notranslate"><span class="pre">303</span></code></p></td>
|
||
<td><p><code class="docutils literal notranslate"><span class="pre">SEE_OTHER</span></code>:已经移动</p></td>
|
||
<td><p>HTTP/1.1 RFC 7231, 6.4.4 节</p></td>
|
||
</tr>
|
||
<tr class="row-odd"><td><p><code class="docutils literal notranslate"><span class="pre">304</span></code></p></td>
|
||
<td><p><code class="docutils literal notranslate"><span class="pre">NOT_MODIFIED</span></code>:没有修改</p></td>
|
||
<td><p>HTTP/1.1 RFC 7232, 4.1 节</p></td>
|
||
</tr>
|
||
<tr class="row-even"><td><p><code class="docutils literal notranslate"><span class="pre">305</span></code></p></td>
|
||
<td><p><code class="docutils literal notranslate"><span class="pre">USE_PROXY</span></code>:使用代理</p></td>
|
||
<td><p>HTTP/1.1 RFC 7231, 6.4.5 节</p></td>
|
||
</tr>
|
||
<tr class="row-odd"><td><p><code class="docutils literal notranslate"><span class="pre">307</span></code></p></td>
|
||
<td><p><code class="docutils literal notranslate"><span class="pre">TEMPORARY_REDIRECT</span></code>:临时重定向</p></td>
|
||
<td><p>HTTP/1.1 <span class="target" id="index-68"></span><a class="rfc reference external" href="https://tools.ietf.org/html/rfc7231.html"><strong>RFC 7231</strong></a>, 6.4.7 节</p></td>
|
||
</tr>
|
||
<tr class="row-even"><td><p><code class="docutils literal notranslate"><span class="pre">308</span></code></p></td>
|
||
<td><p><code class="docutils literal notranslate"><span class="pre">PERMANENT_REDIRECT</span></code>:永久重定向</p></td>
|
||
<td><p>Permanent Redirect <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>, Section 3 (Experimental)</p></td>
|
||
</tr>
|
||
<tr class="row-odd"><td><p><code class="docutils literal notranslate"><span class="pre">400</span></code></p></td>
|
||
<td><p><code class="docutils literal notranslate"><span class="pre">BAD_REQUEST</span></code>:错误请求</p></td>
|
||
<td><p>HTTP/1.1 RFC 7231, 6.5.1 节</p></td>
|
||
</tr>
|
||
<tr class="row-even"><td><p><code class="docutils literal notranslate"><span class="pre">401</span></code></p></td>
|
||
<td><p><code class="docutils literal notranslate"><span class="pre">UNAUTHORIZED</span></code>:未授权</p></td>
|
||
<td><p>HTTP/1.1 Authentication RFC 7235, 3.1 节</p></td>
|
||
</tr>
|
||
<tr class="row-odd"><td><p><code class="docutils literal notranslate"><span class="pre">402</span></code></p></td>
|
||
<td><p><code class="docutils literal notranslate"><span class="pre">PAYMENT_REQUIRED</span></code>:保留,将来使用</p></td>
|
||
<td><p>HTTP/1.1 RFC 7231, 6.5.2 节</p></td>
|
||
</tr>
|
||
<tr class="row-even"><td><p><code class="docutils literal notranslate"><span class="pre">403</span></code></p></td>
|
||
<td><p><code class="docutils literal notranslate"><span class="pre">FORBIDDEN</span></code>:禁止</p></td>
|
||
<td><p>HTTP/1.1 RFC 7231, 6.5.3 节</p></td>
|
||
</tr>
|
||
<tr class="row-odd"><td><p><code class="docutils literal notranslate"><span class="pre">404</span></code></p></td>
|
||
<td><p><code class="docutils literal notranslate"><span class="pre">NOT_FOUND</span></code>:没有找到</p></td>
|
||
<td><p>HTTP/1.1 RFC 7231, 6.5.4 节</p></td>
|
||
</tr>
|
||
<tr class="row-even"><td><p><code class="docutils literal notranslate"><span class="pre">405</span></code></p></td>
|
||
<td><p><code class="docutils literal notranslate"><span class="pre">METHOD_NOT_ALLOWED</span></code>:该请求方法不允许</p></td>
|
||
<td><p>HTTP/1.1 RFC 7231, 6.5.5 节</p></td>
|
||
</tr>
|
||
<tr class="row-odd"><td><p><code class="docutils literal notranslate"><span class="pre">406</span></code></p></td>
|
||
<td><p><code class="docutils literal notranslate"><span class="pre">NOT_ACCEPTABLE</span></code>:不可接受</p></td>
|
||
<td><p>HTTP/1.1 RFC 7231, 6.5.6 节</p></td>
|
||
</tr>
|
||
<tr class="row-even"><td><p><code class="docutils literal notranslate"><span class="pre">407</span></code></p></td>
|
||
<td><p><code class="docutils literal notranslate"><span class="pre">PROXY_AUTHENTICATION_REQUIRED</span></code>:要求使用代理验明正身</p></td>
|
||
<td><p>HTTP/1.1 Authentication RFC 7235, 3.1 节</p></td>
|
||
</tr>
|
||
<tr class="row-odd"><td><p><code class="docutils literal notranslate"><span class="pre">408</span></code></p></td>
|
||
<td><p><code class="docutils literal notranslate"><span class="pre">REQUEST_TIMEOUT</span></code>:请求超时</p></td>
|
||
<td><p>HTTP/1.1 <span class="target" id="index-69"></span><a class="rfc reference external" href="https://tools.ietf.org/html/rfc7231.html"><strong>RFC 7231</strong></a>, 6.5.7 节</p></td>
|
||
</tr>
|
||
<tr class="row-even"><td><p><code class="docutils literal notranslate"><span class="pre">409</span></code></p></td>
|
||
<td><p><code class="docutils literal notranslate"><span class="pre">CONFLICT</span></code>:冲突</p></td>
|
||
<td><p>HTTP/1.1 RFC 7231, 6.5.8 节</p></td>
|
||
</tr>
|
||
<tr class="row-odd"><td><p><code class="docutils literal notranslate"><span class="pre">410</span></code></p></td>
|
||
<td><p><code class="docutils literal notranslate"><span class="pre">GONE</span></code>:已经不在了</p></td>
|
||
<td><p>HTTP/1.1 RFC 7231, 6.5.9 节</p></td>
|
||
</tr>
|
||
<tr class="row-even"><td><p><code class="docutils literal notranslate"><span class="pre">411</span></code></p></td>
|
||
<td><p><code class="docutils literal notranslate"><span class="pre">LENGTH_REQUIRED</span></code>:长度要求</p></td>
|
||
<td><p>HTTP/1.1 RFC 7231, 6.5.10 节</p></td>
|
||
</tr>
|
||
<tr class="row-odd"><td><p><code class="docutils literal notranslate"><span class="pre">412</span></code></p></td>
|
||
<td><p><code class="docutils literal notranslate"><span class="pre">PRECONDITION_FAILED</span></code>:前提条件错误</p></td>
|
||
<td><p>HTTP/1.1 RFC 7232, 4.2 节</p></td>
|
||
</tr>
|
||
<tr class="row-even"><td><p><code class="docutils literal notranslate"><span class="pre">413</span></code></p></td>
|
||
<td><p><code class="docutils literal notranslate"><span class="pre">REQUEST_ENTITY_TOO_LARGE</span></code>:请求体太大了</p></td>
|
||
<td><p>HTTP/1.1 RFC 7231, 6.5.11 节</p></td>
|
||
</tr>
|
||
<tr class="row-odd"><td><p><code class="docutils literal notranslate"><span class="pre">414</span></code></p></td>
|
||
<td><p><code class="docutils literal notranslate"><span class="pre">REQUEST_URI_TOO_LONG</span></code>:请求URI太长了</p></td>
|
||
<td><p>HTTP/1.1 RFC 7231, 6.5.12 节</p></td>
|
||
</tr>
|
||
<tr class="row-even"><td><p><code class="docutils literal notranslate"><span class="pre">415</span></code></p></td>
|
||
<td><p><code class="docutils literal notranslate"><span class="pre">UNSUPPORTED_MEDIA_TYPE</span></code>:不支持的媒体格式</p></td>
|
||
<td><p>HTTP/1.1 RFC 7231, 6.5.13 节</p></td>
|
||
</tr>
|
||
<tr class="row-odd"><td><p><code class="docutils literal notranslate"><span class="pre">416</span></code></p></td>
|
||
<td><p><code class="docutils literal notranslate"><span class="pre">REQUESTED_RANGE_NOT_SATISFIABLE</span></code></p></td>
|
||
<td><p>HTTP/1.1 Range Requests RFC 7233, 4.4 节</p></td>
|
||
</tr>
|
||
<tr class="row-even"><td><p><code class="docutils literal notranslate"><span class="pre">417</span></code></p></td>
|
||
<td><p><code class="docutils literal notranslate"><span class="pre">EXPECTATION_FAILED</span></code>:期望失败</p></td>
|
||
<td><p>HTTP/1.1 RFC 7231, 6.5.14 节</p></td>
|
||
</tr>
|
||
<tr class="row-odd"><td><p><code class="docutils literal notranslate"><span class="pre">421</span></code></p></td>
|
||
<td><p><code class="docutils literal notranslate"><span class="pre">MISDIRECTED_REQUEST</span></code></p></td>
|
||
<td><p>HTTP/2 <span class="target" id="index-70"></span><a class="rfc reference external" href="https://tools.ietf.org/html/rfc7540.html"><strong>RFC 7540</strong></a>, 9.1.2 节</p></td>
|
||
</tr>
|
||
<tr class="row-even"><td><p><code class="docutils literal notranslate"><span class="pre">422</span></code></p></td>
|
||
<td><p><code class="docutils literal notranslate"><span class="pre">UNPROCESSABLE_ENTITY</span></code>:可加工实体</p></td>
|
||
<td><p>WebDAV RFC 4918, 11.2 节</p></td>
|
||
</tr>
|
||
<tr class="row-odd"><td><p><code class="docutils literal notranslate"><span class="pre">423</span></code></p></td>
|
||
<td><p><code class="docutils literal notranslate"><span class="pre">LOCKED</span></code>:锁着</p></td>
|
||
<td><p>WebDAV RFC 4918, 11.3 节</p></td>
|
||
</tr>
|
||
<tr class="row-even"><td><p><code class="docutils literal notranslate"><span class="pre">424</span></code></p></td>
|
||
<td><p><code class="docutils literal notranslate"><span class="pre">FAILED_DEPENDENCY</span></code>:失败的依赖</p></td>
|
||
<td><p>WebDAV RFC 4918, 11.4 节</p></td>
|
||
</tr>
|
||
<tr class="row-odd"><td><p><code class="docutils literal notranslate"><span class="pre">426</span></code></p></td>
|
||
<td><p><code class="docutils literal notranslate"><span class="pre">UPGRADE_REQUIRED</span></code>:升级需要</p></td>
|
||
<td><p>HTTP/1.1 RFC 7231, 6.5.15 节</p></td>
|
||
</tr>
|
||
<tr class="row-even"><td><p><code class="docutils literal notranslate"><span class="pre">428</span></code></p></td>
|
||
<td><p><code class="docutils literal notranslate"><span class="pre">PRECONDITION_REQUIRED</span></code>:先决条件要求</p></td>
|
||
<td><p>Additional HTTP Status Codes RFC 6585</p></td>
|
||
</tr>
|
||
<tr class="row-odd"><td><p><code class="docutils literal notranslate"><span class="pre">429</span></code></p></td>
|
||
<td><p><code class="docutils literal notranslate"><span class="pre">TOO_MANY_REQUESTS</span></code>:太多的请求</p></td>
|
||
<td><p>Additional HTTP Status Codes RFC 6585</p></td>
|
||
</tr>
|
||
<tr class="row-even"><td><p><code class="docutils literal notranslate"><span class="pre">431</span></code></p></td>
|
||
<td><p><code class="docutils literal notranslate"><span class="pre">REQUEST_HEADER_FIELDS_TOO_LARGE</span></code>:请求头太大</p></td>
|
||
<td><p>Additional HTTP Status Codes RFC 6585</p></td>
|
||
</tr>
|
||
<tr class="row-odd"><td><p><code class="docutils literal notranslate"><span class="pre">451</span></code></p></td>
|
||
<td><p><code class="docutils literal notranslate"><span class="pre">UNAVAILABLE_FOR_LEGAL_REASONS</span></code></p></td>
|
||
<td><p>HTTP 状态码用于报告法律障碍 <span class="target" id="index-71"></span><a class="rfc reference external" href="https://tools.ietf.org/html/rfc7725.html"><strong>RFC 7725</strong></a></p></td>
|
||
</tr>
|
||
<tr class="row-even"><td><p><code class="docutils literal notranslate"><span class="pre">500</span></code></p></td>
|
||
<td><p><code class="docutils literal notranslate"><span class="pre">INTERNAL_SERVER_ERROR</span></code>:内部服务错误</p></td>
|
||
<td><p>HTTP/1.1 RFC 7231, 6.6.1 节</p></td>
|
||
</tr>
|
||
<tr class="row-odd"><td><p><code class="docutils literal notranslate"><span class="pre">501</span></code></p></td>
|
||
<td><p><code class="docutils literal notranslate"><span class="pre">NOT_IMPLEMENTED</span></code>:不可执行</p></td>
|
||
<td><p>HTTP/1.1 RFC 7231, 6.6.2 节</p></td>
|
||
</tr>
|
||
<tr class="row-even"><td><p><code class="docutils literal notranslate"><span class="pre">502</span></code></p></td>
|
||
<td><p><code class="docutils literal notranslate"><span class="pre">BAD_GATEWAY</span></code>:无效网关</p></td>
|
||
<td><p>HTTP/1.1 RFC 7231, 6.6.3 节</p></td>
|
||
</tr>
|
||
<tr class="row-odd"><td><p><code class="docutils literal notranslate"><span class="pre">503</span></code></p></td>
|
||
<td><p><code class="docutils literal notranslate"><span class="pre">SERVICE_UNAVAILABLE</span></code>:服务不可用</p></td>
|
||
<td><p>HTTP/1.1 RFC 7231, 6.6.4 节</p></td>
|
||
</tr>
|
||
<tr class="row-even"><td><p><code class="docutils literal notranslate"><span class="pre">504</span></code></p></td>
|
||
<td><p><code class="docutils literal notranslate"><span class="pre">GATEWAY_TIMEOUT</span></code>:网关超时</p></td>
|
||
<td><p>HTTP/1.1 RFC 7231, 6.6.5 节</p></td>
|
||
</tr>
|
||
<tr class="row-odd"><td><p><code class="docutils literal notranslate"><span class="pre">505</span></code></p></td>
|
||
<td><p><code class="docutils literal notranslate"><span class="pre">HTTP_VERSION_NOT_SUPPORTED</span></code>:HTTP版本不支持</p></td>
|
||
<td><p>HTTP/1.1 RFC 7231, 6.6.6 节</p></td>
|
||
</tr>
|
||
<tr class="row-even"><td><p><code class="docutils literal notranslate"><span class="pre">506</span></code></p></td>
|
||
<td><p><code class="docutils literal notranslate"><span class="pre">VARIANT_ALSO_NEGOTIATES</span></code>:服务器存在内部配置错误</p></td>
|
||
<td><p>透明内容协商在: HTTP <span class="target" id="index-72"></span><a class="rfc reference external" href="https://tools.ietf.org/html/rfc2295.html"><strong>RFC 2295</strong></a>, 8.1 节(实验性)</p></td>
|
||
</tr>
|
||
<tr class="row-odd"><td><p><code class="docutils literal notranslate"><span class="pre">507</span></code></p></td>
|
||
<td><p><code class="docutils literal notranslate"><span class="pre">INSUFFICIENT_STORAGE</span></code>:存储不足</p></td>
|
||
<td><p>WebDAV RFC 4918, 11.5 节</p></td>
|
||
</tr>
|
||
<tr class="row-even"><td><p><code class="docutils literal notranslate"><span class="pre">508</span></code></p></td>
|
||
<td><p><code class="docutils literal notranslate"><span class="pre">LOOP_DETECTED</span></code>:循环检测</p></td>
|
||
<td><p>WebDAV Binding Extensions RFC 5842, 7.2 节(实验性)</p></td>
|
||
</tr>
|
||
<tr class="row-odd"><td><p><code class="docutils literal notranslate"><span class="pre">510</span></code></p></td>
|
||
<td><p><code class="docutils literal notranslate"><span class="pre">NOT_EXTENDED</span></code>:不扩展</p></td>
|
||
<td><p>WebDAV Binding Extensions RFC 5842, 7.2 节(实验性)</p></td>
|
||
</tr>
|
||
<tr class="row-even"><td><p><code class="docutils literal notranslate"><span class="pre">511</span></code></p></td>
|
||
<td><p><code class="docutils literal notranslate"><span class="pre">NETWORK_AUTHENTICATION_REQUIRED</span></code>:要求网络身份验证</p></td>
|
||
<td><p>Additional HTTP Status Codes <span class="target" id="index-73"></span><a class="rfc reference external" href="https://tools.ietf.org/html/rfc6585.html"><strong>RFC 6585</strong></a>, 6 节</p></td>
|
||
</tr>
|
||
</tbody>
|
||
</table>
|
||
<p>为了保持向后兼容性,枚举值也以常量形式出现在 <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 notranslate"><span class="pre">http.client</span></code></a> 模块中,。 枚举名等于常量名 (例如 <code class="docutils literal notranslate"><span class="pre">http.HTTPStatus.OK</span></code> 也可以是 <code class="docutils literal notranslate"><span class="pre">http.client.OK</span></code>)。</p>
|
||
<div class="versionchanged">
|
||
<p><span class="versionmodified changed">在 3.7 版更改: </span>添加了 <code class="docutils literal notranslate"><span class="pre">421</span> <span class="pre">MISDIRECTED_REQUEST</span></code> 状态码。</p>
|
||
</div>
|
||
<div class="versionadded">
|
||
<p><span class="versionmodified added">3.8 新版功能: </span>添加了 <code class="docutils literal notranslate"><span class="pre">451</span> <span class="pre">UNAVAILABLE_FOR_LEGAL_REASONS</span></code> 状态码。</p>
|
||
</div>
|
||
</section>
|
||
</section>
|
||
|
||
|
||
</div>
|
||
</div>
|
||
</div>
|
||
<div class="sphinxsidebar" role="navigation" aria-label="main navigation">
|
||
<div class="sphinxsidebarwrapper">
|
||
<h3><a href="../contents.html">目录</a></h3>
|
||
<ul>
|
||
<li><a class="reference internal" href="#"><code class="xref py py-mod docutils literal notranslate"><span class="pre">http</span></code> --- HTTP 模块</a><ul>
|
||
<li><a class="reference internal" href="#http-status-codes">HTTP 状态码</a></li>
|
||
</ul>
|
||
</li>
|
||
</ul>
|
||
|
||
<h4>上一个主题</h4>
|
||
<p class="topless"><a href="urllib.robotparser.html"
|
||
title="上一章"><code class="xref py py-mod docutils literal notranslate"><span class="pre">urllib.robotparser</span></code> --- robots.txt 语法分析程序</a></p>
|
||
<h4>下一个主题</h4>
|
||
<p class="topless"><a href="http.client.html"
|
||
title="下一章"><code class="xref py py-mod docutils literal notranslate"><span class="pre">http.client</span></code> --- HTTP 协议客户端</a></p>
|
||
<div role="note" aria-label="source link">
|
||
<h3>本页</h3>
|
||
<ul class="this-page-menu">
|
||
<li><a href="../bugs.html">报告 Bug</a></li>
|
||
<li>
|
||
<a href="https://github.com/python/cpython/blob/3.8/Doc/library/http.rst"
|
||
rel="nofollow">显示源代码
|
||
</a>
|
||
</li>
|
||
</ul>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
<div class="clearer"></div>
|
||
</div>
|
||
<div class="related" role="navigation" aria-label="related navigation">
|
||
<h3>导航</h3>
|
||
<ul>
|
||
<li class="right" style="margin-right: 10px">
|
||
<a href="../genindex.html" title="总目录"
|
||
>索引</a></li>
|
||
<li class="right" >
|
||
<a href="../py-modindex.html" title="Python 模块索引"
|
||
>模块</a> |</li>
|
||
<li class="right" >
|
||
<a href="http.client.html" title="http.client --- HTTP 协议客户端"
|
||
>下一页</a> |</li>
|
||
<li class="right" >
|
||
<a href="urllib.robotparser.html" title="urllib.robotparser --- robots.txt 语法分析程序"
|
||
>上一页</a> |</li>
|
||
|
||
<li><img src="../_static/py.svg" alt="python logo" style="vertical-align: middle; margin-top: -1px"/></li>
|
||
<li><a href="https://www.python.org/">Python</a> »</li>
|
||
<li class="switchers">
|
||
<div class="language_switcher_placeholder"></div>
|
||
<div class="version_switcher_placeholder"></div>
|
||
</li>
|
||
<li>
|
||
|
||
</li>
|
||
<li id="cpython-language-and-version">
|
||
<a href="../index.html">3.8.20 Documentation</a> »
|
||
</li>
|
||
|
||
<li class="nav-item nav-item-1"><a href="index.html" >Python 标准库</a> »</li>
|
||
<li class="nav-item nav-item-2"><a href="internet.html" >互联网协议和支持</a> »</li>
|
||
<li class="right">
|
||
|
||
|
||
<div class="inline-search" role="search">
|
||
<form class="inline-search" action="../search.html" method="get">
|
||
<input placeholder="快速搜索" aria-label="快速搜索" type="text" name="q" />
|
||
<input type="submit" value="转向" />
|
||
<input type="hidden" name="check_keywords" value="yes" />
|
||
<input type="hidden" name="area" value="default" />
|
||
</form>
|
||
</div>
|
||
|
|
||
</li>
|
||
|
||
</ul>
|
||
</div>
|
||
<div class="footer">
|
||
© <a href="../copyright.html">版权所有</a> 2001-2024, Python Software Foundation.
|
||
<br />
|
||
This page is licensed under the Python Software Foundation License Version 2.
|
||
<br />
|
||
Examples, recipes, and other code in the documentation are additionally licensed under the Zero Clause BSD License.
|
||
<br />
|
||
|
||
<br />
|
||
|
||
The Python Software Foundation is a non-profit corporation.
|
||
<a href="https://www.python.org/psf/donations/">Please donate.</a>
|
||
<br />
|
||
<br />
|
||
|
||
最后更新于 12月 09, 2024.
|
||
<a href="https://docs.python.org/3/bugs.html">Found a bug</a>?
|
||
<br />
|
||
|
||
Created using <a href="https://www.sphinx-doc.org/">Sphinx</a> 2.4.4.
|
||
</div>
|
||
|
||
</body>
|
||
</html> |