gooderp18绿色标准版
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

780 lines
59KB

  1. <!DOCTYPE html>
  2. <html lang="en" data-content_root="../">
  3. <head>
  4. <meta charset="utf-8" />
  5. <meta name="viewport" content="width=device-width, initial-scale=1.0" /><meta name="viewport" content="width=device-width, initial-scale=1" />
  6. <meta property="og:title" content="http — HTTP modules" />
  7. <meta property="og:type" content="website" />
  8. <meta property="og:url" content="https://docs.python.org/3/library/http.html" />
  9. <meta property="og:site_name" content="Python documentation" />
  10. <meta property="og:description" content="Source code: Lib/http/__init__.py http is a package that collects several modules for working with the HyperText Transfer Protocol: http.client is a low-level HTTP protocol client; for high-level U..." />
  11. <meta property="og:image" content="https://docs.python.org/3/_static/og-image.png" />
  12. <meta property="og:image:alt" content="Python documentation" />
  13. <meta name="description" content="Source code: Lib/http/__init__.py http is a package that collects several modules for working with the HyperText Transfer Protocol: http.client is a low-level HTTP protocol client; for high-level U..." />
  14. <meta property="og:image:width" content="200" />
  15. <meta property="og:image:height" content="200" />
  16. <meta name="theme-color" content="#3776ab" />
  17. <title>http — HTTP modules &#8212; Python 3.12.3 documentation</title><meta name="viewport" content="width=device-width, initial-scale=1.0">
  18. <link rel="stylesheet" type="text/css" href="../_static/pygments.css?v=80d5e7a1" />
  19. <link rel="stylesheet" type="text/css" href="../_static/pydoctheme.css?v=bb723527" />
  20. <link id="pygments_dark_css" media="(prefers-color-scheme: dark)" rel="stylesheet" type="text/css" href="../_static/pygments_dark.css?v=b20cc3f5" />
  21. <script src="../_static/documentation_options.js?v=2c828074"></script>
  22. <script src="../_static/doctools.js?v=888ff710"></script>
  23. <script src="../_static/sphinx_highlight.js?v=dc90522c"></script>
  24. <script src="../_static/sidebar.js"></script>
  25. <link rel="search" type="application/opensearchdescription+xml"
  26. title="Search within Python 3.12.3 documentation"
  27. href="../_static/opensearch.xml"/>
  28. <link rel="author" title="About these documents" href="../about.html" />
  29. <link rel="index" title="Index" href="../genindex.html" />
  30. <link rel="search" title="Search" href="../search.html" />
  31. <link rel="copyright" title="Copyright" href="../copyright.html" />
  32. <link rel="next" title="http.client — HTTP protocol client" href="http.client.html" />
  33. <link rel="prev" title="urllib.robotparser — Parser for robots.txt" href="urllib.robotparser.html" />
  34. <link rel="canonical" href="https://docs.python.org/3/library/http.html" />
  35. <style>
  36. @media only screen {
  37. table.full-width-table {
  38. width: 100%;
  39. }
  40. }
  41. </style>
  42. <link rel="stylesheet" href="../_static/pydoctheme_dark.css" media="(prefers-color-scheme: dark)" id="pydoctheme_dark_css">
  43. <link rel="shortcut icon" type="image/png" href="../_static/py.svg" />
  44. <script type="text/javascript" src="../_static/copybutton.js"></script>
  45. <script type="text/javascript" src="../_static/menu.js"></script>
  46. <script type="text/javascript" src="../_static/search-focus.js"></script>
  47. <script type="text/javascript" src="../_static/themetoggle.js"></script>
  48. </head>
  49. <body>
  50. <div class="mobile-nav">
  51. <input type="checkbox" id="menuToggler" class="toggler__input" aria-controls="navigation"
  52. aria-pressed="false" aria-expanded="false" role="button" aria-label="Menu" />
  53. <nav class="nav-content" role="navigation">
  54. <label for="menuToggler" class="toggler__label">
  55. <span></span>
  56. </label>
  57. <span class="nav-items-wrapper">
  58. <a href="https://www.python.org/" class="nav-logo">
  59. <img src="../_static/py.svg" alt="Python logo"/>
  60. </a>
  61. <span class="version_switcher_placeholder"></span>
  62. <form role="search" class="search" action="../search.html" method="get">
  63. <svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" class="search-icon">
  64. <path fill-rule="nonzero" fill="currentColor" 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"></path>
  65. </svg>
  66. <input placeholder="Quick search" aria-label="Quick search" type="search" name="q" />
  67. <input type="submit" value="Go"/>
  68. </form>
  69. </span>
  70. </nav>
  71. <div class="menu-wrapper">
  72. <nav class="menu" role="navigation" aria-label="main navigation">
  73. <div class="language_switcher_placeholder"></div>
  74. <label class="theme-selector-label">
  75. Theme
  76. <select class="theme-selector" oninput="activateTheme(this.value)">
  77. <option value="auto" selected>Auto</option>
  78. <option value="light">Light</option>
  79. <option value="dark">Dark</option>
  80. </select>
  81. </label>
  82. <div>
  83. <h3><a href="../contents.html">Table of Contents</a></h3>
  84. <ul>
  85. <li><a class="reference internal" href="#"><code class="xref py py-mod docutils literal notranslate"><span class="pre">http</span></code> — HTTP modules</a><ul>
  86. <li><a class="reference internal" href="#http-status-codes">HTTP status codes</a></li>
  87. <li><a class="reference internal" href="#http-status-category">HTTP status category</a></li>
  88. <li><a class="reference internal" href="#http-methods">HTTP methods</a></li>
  89. </ul>
  90. </li>
  91. </ul>
  92. </div>
  93. <div>
  94. <h4>Previous topic</h4>
  95. <p class="topless"><a href="urllib.robotparser.html"
  96. title="previous chapter"><code class="xref py py-mod docutils literal notranslate"><span class="pre">urllib.robotparser</span></code> — Parser for robots.txt</a></p>
  97. </div>
  98. <div>
  99. <h4>Next topic</h4>
  100. <p class="topless"><a href="http.client.html"
  101. title="next chapter"><code class="xref py py-mod docutils literal notranslate"><span class="pre">http.client</span></code> — HTTP protocol client</a></p>
  102. </div>
  103. <div role="note" aria-label="source link">
  104. <h3>This Page</h3>
  105. <ul class="this-page-menu">
  106. <li><a href="../bugs.html">Report a Bug</a></li>
  107. <li>
  108. <a href="https://github.com/python/cpython/blob/main/Doc/library/http.rst"
  109. rel="nofollow">Show Source
  110. </a>
  111. </li>
  112. </ul>
  113. </div>
  114. </nav>
  115. </div>
  116. </div>
  117. <div class="related" role="navigation" aria-label="related navigation">
  118. <h3>Navigation</h3>
  119. <ul>
  120. <li class="right" style="margin-right: 10px">
  121. <a href="../genindex.html" title="General Index"
  122. accesskey="I">index</a></li>
  123. <li class="right" >
  124. <a href="../py-modindex.html" title="Python Module Index"
  125. >modules</a> |</li>
  126. <li class="right" >
  127. <a href="http.client.html" title="http.client — HTTP protocol client"
  128. accesskey="N">next</a> |</li>
  129. <li class="right" >
  130. <a href="urllib.robotparser.html" title="urllib.robotparser — Parser for robots.txt"
  131. accesskey="P">previous</a> |</li>
  132. <li><img src="../_static/py.svg" alt="Python logo" style="vertical-align: middle; margin-top: -1px"/></li>
  133. <li><a href="https://www.python.org/">Python</a> &#187;</li>
  134. <li class="switchers">
  135. <div class="language_switcher_placeholder"></div>
  136. <div class="version_switcher_placeholder"></div>
  137. </li>
  138. <li>
  139. </li>
  140. <li id="cpython-language-and-version">
  141. <a href="../index.html">3.12.3 Documentation</a> &#187;
  142. </li>
  143. <li class="nav-item nav-item-1"><a href="index.html" >The Python Standard Library</a> &#187;</li>
  144. <li class="nav-item nav-item-2"><a href="internet.html" accesskey="U">Internet Protocols and Support</a> &#187;</li>
  145. <li class="nav-item nav-item-this"><a href=""><code class="xref py py-mod docutils literal notranslate"><span class="pre">http</span></code> — HTTP modules</a></li>
  146. <li class="right">
  147. <div class="inline-search" role="search">
  148. <form class="inline-search" action="../search.html" method="get">
  149. <input placeholder="Quick search" aria-label="Quick search" type="search" name="q" id="search-box" />
  150. <input type="submit" value="Go" />
  151. </form>
  152. </div>
  153. |
  154. </li>
  155. <li class="right">
  156. <label class="theme-selector-label">
  157. Theme
  158. <select class="theme-selector" oninput="activateTheme(this.value)">
  159. <option value="auto" selected>Auto</option>
  160. <option value="light">Light</option>
  161. <option value="dark">Dark</option>
  162. </select>
  163. </label> |</li>
  164. </ul>
  165. </div>
  166. <div class="document">
  167. <div class="documentwrapper">
  168. <div class="bodywrapper">
  169. <div class="body" role="main">
  170. <section id="module-http">
  171. <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 modules<a class="headerlink" href="#module-http" title="Link to this heading">¶</a></h1>
  172. <p><strong>Source code:</strong> <a class="reference external" href="https://github.com/python/cpython/tree/3.12/Lib/http/__init__.py">Lib/http/__init__.py</a></p>
  173. <hr class="docutils" id="index-0" />
  174. <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> is a package that collects several modules for working with the
  175. HyperText Transfer Protocol:</p>
  176. <ul class="simple">
  177. <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> is a low-level HTTP protocol client; for high-level URL
  178. opening use <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>
  179. <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> contains basic HTTP server classes based on <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></p></li>
  180. <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> has utilities for implementing state management with cookies</p></li>
  181. <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> provides persistence of cookies</p></li>
  182. </ul>
  183. <p>The <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> module also defines the following enums that help you work with http related code:</p>
  184. <dl class="py class">
  185. <dt class="sig sig-object py" id="http.HTTPStatus">
  186. <em class="property"><span class="pre">class</span><span class="w"> </span></em><span class="sig-prename descclassname"><span class="pre">http.</span></span><span class="sig-name descname"><span class="pre">HTTPStatus</span></span><a class="headerlink" href="#http.HTTPStatus" title="Link to this definition">¶</a></dt>
  187. <dd><div class="versionadded">
  188. <p><span class="versionmodified added">New in version 3.5.</span></p>
  189. </div>
  190. <p>A subclass of <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> that defines a set of HTTP status codes,
  191. reason phrases and long descriptions written in English.</p>
  192. <p>Usage:</p>
  193. <div class="highlight-python3 notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">http</span> <span class="kn">import</span> <span class="n">HTTPStatus</span>
  194. <span class="gp">&gt;&gt;&gt; </span><span class="n">HTTPStatus</span><span class="o">.</span><span class="n">OK</span>
  195. <span class="go">HTTPStatus.OK</span>
  196. <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>
  197. <span class="go">True</span>
  198. <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">value</span>
  199. <span class="go">200</span>
  200. <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>
  201. <span class="go">&#39;OK&#39;</span>
  202. <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>
  203. <span class="go">&#39;Request fulfilled, document follows&#39;</span>
  204. <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>
  205. <span class="go">[HTTPStatus.CONTINUE, HTTPStatus.SWITCHING_PROTOCOLS, ...]</span>
  206. </pre></div>
  207. </div>
  208. </dd></dl>
  209. <section id="http-status-codes">
  210. <span id="id1"></span><h2>HTTP status codes<a class="headerlink" href="#http-status-codes" title="Link to this heading">¶</a></h2>
  211. <p>Supported,
  212. <a class="reference external" href="https://www.iana.org/assignments/http-status-codes/http-status-codes.xhtml">IANA-registered status codes</a>
  213. available in <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> are:</p>
  214. <table class="docutils align-default">
  215. <thead>
  216. <tr class="row-odd"><th class="head"><p>Code</p></th>
  217. <th class="head"><p>Enum Name</p></th>
  218. <th class="head"><p>Details</p></th>
  219. </tr>
  220. </thead>
  221. <tbody>
  222. <tr class="row-even"><td><p><code class="docutils literal notranslate"><span class="pre">100</span></code></p></td>
  223. <td><p><code class="docutils literal notranslate"><span class="pre">CONTINUE</span></code></p></td>
  224. <td><p>HTTP/1.1 <span class="target" id="index-1"></span><a class="rfc reference external" href="https://datatracker.ietf.org/doc/html/rfc7231.html"><strong>RFC 7231</strong></a>, Section 6.2.1</p></td>
  225. </tr>
  226. <tr class="row-odd"><td><p><code class="docutils literal notranslate"><span class="pre">101</span></code></p></td>
  227. <td><p><code class="docutils literal notranslate"><span class="pre">SWITCHING_PROTOCOLS</span></code></p></td>
  228. <td><p>HTTP/1.1 <span class="target" id="index-2"></span><a class="rfc reference external" href="https://datatracker.ietf.org/doc/html/rfc7231.html"><strong>RFC 7231</strong></a>, Section 6.2.2</p></td>
  229. </tr>
  230. <tr class="row-even"><td><p><code class="docutils literal notranslate"><span class="pre">102</span></code></p></td>
  231. <td><p><code class="docutils literal notranslate"><span class="pre">PROCESSING</span></code></p></td>
  232. <td><p>WebDAV <span class="target" id="index-3"></span><a class="rfc reference external" href="https://datatracker.ietf.org/doc/html/rfc2518.html"><strong>RFC 2518</strong></a>, Section 10.1</p></td>
  233. </tr>
  234. <tr class="row-odd"><td><p><code class="docutils literal notranslate"><span class="pre">103</span></code></p></td>
  235. <td><p><code class="docutils literal notranslate"><span class="pre">EARLY_HINTS</span></code></p></td>
  236. <td><p>An HTTP Status Code for Indicating Hints <span class="target" id="index-4"></span><a class="rfc reference external" href="https://datatracker.ietf.org/doc/html/rfc8297.html"><strong>RFC 8297</strong></a></p></td>
  237. </tr>
  238. <tr class="row-even"><td><p><code class="docutils literal notranslate"><span class="pre">200</span></code></p></td>
  239. <td><p><code class="docutils literal notranslate"><span class="pre">OK</span></code></p></td>
  240. <td><p>HTTP/1.1 <span class="target" id="index-5"></span><a class="rfc reference external" href="https://datatracker.ietf.org/doc/html/rfc7231.html"><strong>RFC 7231</strong></a>, Section 6.3.1</p></td>
  241. </tr>
  242. <tr class="row-odd"><td><p><code class="docutils literal notranslate"><span class="pre">201</span></code></p></td>
  243. <td><p><code class="docutils literal notranslate"><span class="pre">CREATED</span></code></p></td>
  244. <td><p>HTTP/1.1 <span class="target" id="index-6"></span><a class="rfc reference external" href="https://datatracker.ietf.org/doc/html/rfc7231.html"><strong>RFC 7231</strong></a>, Section 6.3.2</p></td>
  245. </tr>
  246. <tr class="row-even"><td><p><code class="docutils literal notranslate"><span class="pre">202</span></code></p></td>
  247. <td><p><code class="docutils literal notranslate"><span class="pre">ACCEPTED</span></code></p></td>
  248. <td><p>HTTP/1.1 <span class="target" id="index-7"></span><a class="rfc reference external" href="https://datatracker.ietf.org/doc/html/rfc7231.html"><strong>RFC 7231</strong></a>, Section 6.3.3</p></td>
  249. </tr>
  250. <tr class="row-odd"><td><p><code class="docutils literal notranslate"><span class="pre">203</span></code></p></td>
  251. <td><p><code class="docutils literal notranslate"><span class="pre">NON_AUTHORITATIVE_INFORMATION</span></code></p></td>
  252. <td><p>HTTP/1.1 <span class="target" id="index-8"></span><a class="rfc reference external" href="https://datatracker.ietf.org/doc/html/rfc7231.html"><strong>RFC 7231</strong></a>, Section 6.3.4</p></td>
  253. </tr>
  254. <tr class="row-even"><td><p><code class="docutils literal notranslate"><span class="pre">204</span></code></p></td>
  255. <td><p><code class="docutils literal notranslate"><span class="pre">NO_CONTENT</span></code></p></td>
  256. <td><p>HTTP/1.1 <span class="target" id="index-9"></span><a class="rfc reference external" href="https://datatracker.ietf.org/doc/html/rfc7231.html"><strong>RFC 7231</strong></a>, Section 6.3.5</p></td>
  257. </tr>
  258. <tr class="row-odd"><td><p><code class="docutils literal notranslate"><span class="pre">205</span></code></p></td>
  259. <td><p><code class="docutils literal notranslate"><span class="pre">RESET_CONTENT</span></code></p></td>
  260. <td><p>HTTP/1.1 <span class="target" id="index-10"></span><a class="rfc reference external" href="https://datatracker.ietf.org/doc/html/rfc7231.html"><strong>RFC 7231</strong></a>, Section 6.3.6</p></td>
  261. </tr>
  262. <tr class="row-even"><td><p><code class="docutils literal notranslate"><span class="pre">206</span></code></p></td>
  263. <td><p><code class="docutils literal notranslate"><span class="pre">PARTIAL_CONTENT</span></code></p></td>
  264. <td><p>HTTP/1.1 <span class="target" id="index-11"></span><a class="rfc reference external" href="https://datatracker.ietf.org/doc/html/rfc7233.html"><strong>RFC 7233</strong></a>, Section 4.1</p></td>
  265. </tr>
  266. <tr class="row-odd"><td><p><code class="docutils literal notranslate"><span class="pre">207</span></code></p></td>
  267. <td><p><code class="docutils literal notranslate"><span class="pre">MULTI_STATUS</span></code></p></td>
  268. <td><p>WebDAV <span class="target" id="index-12"></span><a class="rfc reference external" href="https://datatracker.ietf.org/doc/html/rfc4918.html"><strong>RFC 4918</strong></a>, Section 11.1</p></td>
  269. </tr>
  270. <tr class="row-even"><td><p><code class="docutils literal notranslate"><span class="pre">208</span></code></p></td>
  271. <td><p><code class="docutils literal notranslate"><span class="pre">ALREADY_REPORTED</span></code></p></td>
  272. <td><p>WebDAV Binding Extensions <span class="target" id="index-13"></span><a class="rfc reference external" href="https://datatracker.ietf.org/doc/html/rfc5842.html"><strong>RFC 5842</strong></a>, Section 7.1 (Experimental)</p></td>
  273. </tr>
  274. <tr class="row-odd"><td><p><code class="docutils literal notranslate"><span class="pre">226</span></code></p></td>
  275. <td><p><code class="docutils literal notranslate"><span class="pre">IM_USED</span></code></p></td>
  276. <td><p>Delta Encoding in HTTP <span class="target" id="index-14"></span><a class="rfc reference external" href="https://datatracker.ietf.org/doc/html/rfc3229.html"><strong>RFC 3229</strong></a>, Section 10.4.1</p></td>
  277. </tr>
  278. <tr class="row-even"><td><p><code class="docutils literal notranslate"><span class="pre">300</span></code></p></td>
  279. <td><p><code class="docutils literal notranslate"><span class="pre">MULTIPLE_CHOICES</span></code></p></td>
  280. <td><p>HTTP/1.1 <span class="target" id="index-15"></span><a class="rfc reference external" href="https://datatracker.ietf.org/doc/html/rfc7231.html"><strong>RFC 7231</strong></a>, Section 6.4.1</p></td>
  281. </tr>
  282. <tr class="row-odd"><td><p><code class="docutils literal notranslate"><span class="pre">301</span></code></p></td>
  283. <td><p><code class="docutils literal notranslate"><span class="pre">MOVED_PERMANENTLY</span></code></p></td>
  284. <td><p>HTTP/1.1 <span class="target" id="index-16"></span><a class="rfc reference external" href="https://datatracker.ietf.org/doc/html/rfc7231.html"><strong>RFC 7231</strong></a>, Section 6.4.2</p></td>
  285. </tr>
  286. <tr class="row-even"><td><p><code class="docutils literal notranslate"><span class="pre">302</span></code></p></td>
  287. <td><p><code class="docutils literal notranslate"><span class="pre">FOUND</span></code></p></td>
  288. <td><p>HTTP/1.1 <span class="target" id="index-17"></span><a class="rfc reference external" href="https://datatracker.ietf.org/doc/html/rfc7231.html"><strong>RFC 7231</strong></a>, Section 6.4.3</p></td>
  289. </tr>
  290. <tr class="row-odd"><td><p><code class="docutils literal notranslate"><span class="pre">303</span></code></p></td>
  291. <td><p><code class="docutils literal notranslate"><span class="pre">SEE_OTHER</span></code></p></td>
  292. <td><p>HTTP/1.1 <span class="target" id="index-18"></span><a class="rfc reference external" href="https://datatracker.ietf.org/doc/html/rfc7231.html"><strong>RFC 7231</strong></a>, Section 6.4.4</p></td>
  293. </tr>
  294. <tr class="row-even"><td><p><code class="docutils literal notranslate"><span class="pre">304</span></code></p></td>
  295. <td><p><code class="docutils literal notranslate"><span class="pre">NOT_MODIFIED</span></code></p></td>
  296. <td><p>HTTP/1.1 <span class="target" id="index-19"></span><a class="rfc reference external" href="https://datatracker.ietf.org/doc/html/rfc7232.html"><strong>RFC 7232</strong></a>, Section 4.1</p></td>
  297. </tr>
  298. <tr class="row-odd"><td><p><code class="docutils literal notranslate"><span class="pre">305</span></code></p></td>
  299. <td><p><code class="docutils literal notranslate"><span class="pre">USE_PROXY</span></code></p></td>
  300. <td><p>HTTP/1.1 <span class="target" id="index-20"></span><a class="rfc reference external" href="https://datatracker.ietf.org/doc/html/rfc7231.html"><strong>RFC 7231</strong></a>, Section 6.4.5</p></td>
  301. </tr>
  302. <tr class="row-even"><td><p><code class="docutils literal notranslate"><span class="pre">307</span></code></p></td>
  303. <td><p><code class="docutils literal notranslate"><span class="pre">TEMPORARY_REDIRECT</span></code></p></td>
  304. <td><p>HTTP/1.1 <span class="target" id="index-21"></span><a class="rfc reference external" href="https://datatracker.ietf.org/doc/html/rfc7231.html"><strong>RFC 7231</strong></a>, Section 6.4.7</p></td>
  305. </tr>
  306. <tr class="row-odd"><td><p><code class="docutils literal notranslate"><span class="pre">308</span></code></p></td>
  307. <td><p><code class="docutils literal notranslate"><span class="pre">PERMANENT_REDIRECT</span></code></p></td>
  308. <td><p>Permanent Redirect <span class="target" id="index-22"></span><a class="rfc reference external" href="https://datatracker.ietf.org/doc/html/rfc7238.html"><strong>RFC 7238</strong></a>, Section 3 (Experimental)</p></td>
  309. </tr>
  310. <tr class="row-even"><td><p><code class="docutils literal notranslate"><span class="pre">400</span></code></p></td>
  311. <td><p><code class="docutils literal notranslate"><span class="pre">BAD_REQUEST</span></code></p></td>
  312. <td><p>HTTP/1.1 <span class="target" id="index-23"></span><a class="rfc reference external" href="https://datatracker.ietf.org/doc/html/rfc7231.html"><strong>RFC 7231</strong></a>, Section 6.5.1</p></td>
  313. </tr>
  314. <tr class="row-odd"><td><p><code class="docutils literal notranslate"><span class="pre">401</span></code></p></td>
  315. <td><p><code class="docutils literal notranslate"><span class="pre">UNAUTHORIZED</span></code></p></td>
  316. <td><p>HTTP/1.1 Authentication <span class="target" id="index-24"></span><a class="rfc reference external" href="https://datatracker.ietf.org/doc/html/rfc7235.html"><strong>RFC 7235</strong></a>, Section 3.1</p></td>
  317. </tr>
  318. <tr class="row-even"><td><p><code class="docutils literal notranslate"><span class="pre">402</span></code></p></td>
  319. <td><p><code class="docutils literal notranslate"><span class="pre">PAYMENT_REQUIRED</span></code></p></td>
  320. <td><p>HTTP/1.1 <span class="target" id="index-25"></span><a class="rfc reference external" href="https://datatracker.ietf.org/doc/html/rfc7231.html"><strong>RFC 7231</strong></a>, Section 6.5.2</p></td>
  321. </tr>
  322. <tr class="row-odd"><td><p><code class="docutils literal notranslate"><span class="pre">403</span></code></p></td>
  323. <td><p><code class="docutils literal notranslate"><span class="pre">FORBIDDEN</span></code></p></td>
  324. <td><p>HTTP/1.1 <span class="target" id="index-26"></span><a class="rfc reference external" href="https://datatracker.ietf.org/doc/html/rfc7231.html"><strong>RFC 7231</strong></a>, Section 6.5.3</p></td>
  325. </tr>
  326. <tr class="row-even"><td><p><code class="docutils literal notranslate"><span class="pre">404</span></code></p></td>
  327. <td><p><code class="docutils literal notranslate"><span class="pre">NOT_FOUND</span></code></p></td>
  328. <td><p>HTTP/1.1 <span class="target" id="index-27"></span><a class="rfc reference external" href="https://datatracker.ietf.org/doc/html/rfc7231.html"><strong>RFC 7231</strong></a>, Section 6.5.4</p></td>
  329. </tr>
  330. <tr class="row-odd"><td><p><code class="docutils literal notranslate"><span class="pre">405</span></code></p></td>
  331. <td><p><code class="docutils literal notranslate"><span class="pre">METHOD_NOT_ALLOWED</span></code></p></td>
  332. <td><p>HTTP/1.1 <span class="target" id="index-28"></span><a class="rfc reference external" href="https://datatracker.ietf.org/doc/html/rfc7231.html"><strong>RFC 7231</strong></a>, Section 6.5.5</p></td>
  333. </tr>
  334. <tr class="row-even"><td><p><code class="docutils literal notranslate"><span class="pre">406</span></code></p></td>
  335. <td><p><code class="docutils literal notranslate"><span class="pre">NOT_ACCEPTABLE</span></code></p></td>
  336. <td><p>HTTP/1.1 <span class="target" id="index-29"></span><a class="rfc reference external" href="https://datatracker.ietf.org/doc/html/rfc7231.html"><strong>RFC 7231</strong></a>, Section 6.5.6</p></td>
  337. </tr>
  338. <tr class="row-odd"><td><p><code class="docutils literal notranslate"><span class="pre">407</span></code></p></td>
  339. <td><p><code class="docutils literal notranslate"><span class="pre">PROXY_AUTHENTICATION_REQUIRED</span></code></p></td>
  340. <td><p>HTTP/1.1 Authentication <span class="target" id="index-30"></span><a class="rfc reference external" href="https://datatracker.ietf.org/doc/html/rfc7235.html"><strong>RFC 7235</strong></a>, Section 3.2</p></td>
  341. </tr>
  342. <tr class="row-even"><td><p><code class="docutils literal notranslate"><span class="pre">408</span></code></p></td>
  343. <td><p><code class="docutils literal notranslate"><span class="pre">REQUEST_TIMEOUT</span></code></p></td>
  344. <td><p>HTTP/1.1 <span class="target" id="index-31"></span><a class="rfc reference external" href="https://datatracker.ietf.org/doc/html/rfc7231.html"><strong>RFC 7231</strong></a>, Section 6.5.7</p></td>
  345. </tr>
  346. <tr class="row-odd"><td><p><code class="docutils literal notranslate"><span class="pre">409</span></code></p></td>
  347. <td><p><code class="docutils literal notranslate"><span class="pre">CONFLICT</span></code></p></td>
  348. <td><p>HTTP/1.1 <span class="target" id="index-32"></span><a class="rfc reference external" href="https://datatracker.ietf.org/doc/html/rfc7231.html"><strong>RFC 7231</strong></a>, Section 6.5.8</p></td>
  349. </tr>
  350. <tr class="row-even"><td><p><code class="docutils literal notranslate"><span class="pre">410</span></code></p></td>
  351. <td><p><code class="docutils literal notranslate"><span class="pre">GONE</span></code></p></td>
  352. <td><p>HTTP/1.1 <span class="target" id="index-33"></span><a class="rfc reference external" href="https://datatracker.ietf.org/doc/html/rfc7231.html"><strong>RFC 7231</strong></a>, Section 6.5.9</p></td>
  353. </tr>
  354. <tr class="row-odd"><td><p><code class="docutils literal notranslate"><span class="pre">411</span></code></p></td>
  355. <td><p><code class="docutils literal notranslate"><span class="pre">LENGTH_REQUIRED</span></code></p></td>
  356. <td><p>HTTP/1.1 <span class="target" id="index-34"></span><a class="rfc reference external" href="https://datatracker.ietf.org/doc/html/rfc7231.html"><strong>RFC 7231</strong></a>, Section 6.5.10</p></td>
  357. </tr>
  358. <tr class="row-even"><td><p><code class="docutils literal notranslate"><span class="pre">412</span></code></p></td>
  359. <td><p><code class="docutils literal notranslate"><span class="pre">PRECONDITION_FAILED</span></code></p></td>
  360. <td><p>HTTP/1.1 <span class="target" id="index-35"></span><a class="rfc reference external" href="https://datatracker.ietf.org/doc/html/rfc7232.html"><strong>RFC 7232</strong></a>, Section 4.2</p></td>
  361. </tr>
  362. <tr class="row-odd"><td><p><code class="docutils literal notranslate"><span class="pre">413</span></code></p></td>
  363. <td><p><code class="docutils literal notranslate"><span class="pre">REQUEST_ENTITY_TOO_LARGE</span></code></p></td>
  364. <td><p>HTTP/1.1 <span class="target" id="index-36"></span><a class="rfc reference external" href="https://datatracker.ietf.org/doc/html/rfc7231.html"><strong>RFC 7231</strong></a>, Section 6.5.11</p></td>
  365. </tr>
  366. <tr class="row-even"><td><p><code class="docutils literal notranslate"><span class="pre">414</span></code></p></td>
  367. <td><p><code class="docutils literal notranslate"><span class="pre">REQUEST_URI_TOO_LONG</span></code></p></td>
  368. <td><p>HTTP/1.1 <span class="target" id="index-37"></span><a class="rfc reference external" href="https://datatracker.ietf.org/doc/html/rfc7231.html"><strong>RFC 7231</strong></a>, Section 6.5.12</p></td>
  369. </tr>
  370. <tr class="row-odd"><td><p><code class="docutils literal notranslate"><span class="pre">415</span></code></p></td>
  371. <td><p><code class="docutils literal notranslate"><span class="pre">UNSUPPORTED_MEDIA_TYPE</span></code></p></td>
  372. <td><p>HTTP/1.1 <span class="target" id="index-38"></span><a class="rfc reference external" href="https://datatracker.ietf.org/doc/html/rfc7231.html"><strong>RFC 7231</strong></a>, Section 6.5.13</p></td>
  373. </tr>
  374. <tr class="row-even"><td><p><code class="docutils literal notranslate"><span class="pre">416</span></code></p></td>
  375. <td><p><code class="docutils literal notranslate"><span class="pre">REQUESTED_RANGE_NOT_SATISFIABLE</span></code></p></td>
  376. <td><p>HTTP/1.1 Range Requests <span class="target" id="index-39"></span><a class="rfc reference external" href="https://datatracker.ietf.org/doc/html/rfc7233.html"><strong>RFC 7233</strong></a>, Section 4.4</p></td>
  377. </tr>
  378. <tr class="row-odd"><td><p><code class="docutils literal notranslate"><span class="pre">417</span></code></p></td>
  379. <td><p><code class="docutils literal notranslate"><span class="pre">EXPECTATION_FAILED</span></code></p></td>
  380. <td><p>HTTP/1.1 <span class="target" id="index-40"></span><a class="rfc reference external" href="https://datatracker.ietf.org/doc/html/rfc7231.html"><strong>RFC 7231</strong></a>, Section 6.5.14</p></td>
  381. </tr>
  382. <tr class="row-even"><td><p><code class="docutils literal notranslate"><span class="pre">418</span></code></p></td>
  383. <td><p><code class="docutils literal notranslate"><span class="pre">IM_A_TEAPOT</span></code></p></td>
  384. <td><p>HTCPCP/1.0 <span class="target" id="index-41"></span><a class="rfc reference external" href="https://datatracker.ietf.org/doc/html/rfc2324.html"><strong>RFC 2324</strong></a>, Section 2.3.2</p></td>
  385. </tr>
  386. <tr class="row-odd"><td><p><code class="docutils literal notranslate"><span class="pre">421</span></code></p></td>
  387. <td><p><code class="docutils literal notranslate"><span class="pre">MISDIRECTED_REQUEST</span></code></p></td>
  388. <td><p>HTTP/2 <span class="target" id="index-42"></span><a class="rfc reference external" href="https://datatracker.ietf.org/doc/html/rfc7540.html"><strong>RFC 7540</strong></a>, Section 9.1.2</p></td>
  389. </tr>
  390. <tr class="row-even"><td><p><code class="docutils literal notranslate"><span class="pre">422</span></code></p></td>
  391. <td><p><code class="docutils literal notranslate"><span class="pre">UNPROCESSABLE_ENTITY</span></code></p></td>
  392. <td><p>WebDAV <span class="target" id="index-43"></span><a class="rfc reference external" href="https://datatracker.ietf.org/doc/html/rfc4918.html"><strong>RFC 4918</strong></a>, Section 11.2</p></td>
  393. </tr>
  394. <tr class="row-odd"><td><p><code class="docutils literal notranslate"><span class="pre">423</span></code></p></td>
  395. <td><p><code class="docutils literal notranslate"><span class="pre">LOCKED</span></code></p></td>
  396. <td><p>WebDAV <span class="target" id="index-44"></span><a class="rfc reference external" href="https://datatracker.ietf.org/doc/html/rfc4918.html"><strong>RFC 4918</strong></a>, Section 11.3</p></td>
  397. </tr>
  398. <tr class="row-even"><td><p><code class="docutils literal notranslate"><span class="pre">424</span></code></p></td>
  399. <td><p><code class="docutils literal notranslate"><span class="pre">FAILED_DEPENDENCY</span></code></p></td>
  400. <td><p>WebDAV <span class="target" id="index-45"></span><a class="rfc reference external" href="https://datatracker.ietf.org/doc/html/rfc4918.html"><strong>RFC 4918</strong></a>, Section 11.4</p></td>
  401. </tr>
  402. <tr class="row-odd"><td><p><code class="docutils literal notranslate"><span class="pre">425</span></code></p></td>
  403. <td><p><code class="docutils literal notranslate"><span class="pre">TOO_EARLY</span></code></p></td>
  404. <td><p>Using Early Data in HTTP <span class="target" id="index-46"></span><a class="rfc reference external" href="https://datatracker.ietf.org/doc/html/rfc8470.html"><strong>RFC 8470</strong></a></p></td>
  405. </tr>
  406. <tr class="row-even"><td><p><code class="docutils literal notranslate"><span class="pre">426</span></code></p></td>
  407. <td><p><code class="docutils literal notranslate"><span class="pre">UPGRADE_REQUIRED</span></code></p></td>
  408. <td><p>HTTP/1.1 <span class="target" id="index-47"></span><a class="rfc reference external" href="https://datatracker.ietf.org/doc/html/rfc7231.html"><strong>RFC 7231</strong></a>, Section 6.5.15</p></td>
  409. </tr>
  410. <tr class="row-odd"><td><p><code class="docutils literal notranslate"><span class="pre">428</span></code></p></td>
  411. <td><p><code class="docutils literal notranslate"><span class="pre">PRECONDITION_REQUIRED</span></code></p></td>
  412. <td><p>Additional HTTP Status Codes <span class="target" id="index-48"></span><a class="rfc reference external" href="https://datatracker.ietf.org/doc/html/rfc6585.html"><strong>RFC 6585</strong></a></p></td>
  413. </tr>
  414. <tr class="row-even"><td><p><code class="docutils literal notranslate"><span class="pre">429</span></code></p></td>
  415. <td><p><code class="docutils literal notranslate"><span class="pre">TOO_MANY_REQUESTS</span></code></p></td>
  416. <td><p>Additional HTTP Status Codes <span class="target" id="index-49"></span><a class="rfc reference external" href="https://datatracker.ietf.org/doc/html/rfc6585.html"><strong>RFC 6585</strong></a></p></td>
  417. </tr>
  418. <tr class="row-odd"><td><p><code class="docutils literal notranslate"><span class="pre">431</span></code></p></td>
  419. <td><p><code class="docutils literal notranslate"><span class="pre">REQUEST_HEADER_FIELDS_TOO_LARGE</span></code></p></td>
  420. <td><p>Additional HTTP Status Codes <span class="target" id="index-50"></span><a class="rfc reference external" href="https://datatracker.ietf.org/doc/html/rfc6585.html"><strong>RFC 6585</strong></a></p></td>
  421. </tr>
  422. <tr class="row-even"><td><p><code class="docutils literal notranslate"><span class="pre">451</span></code></p></td>
  423. <td><p><code class="docutils literal notranslate"><span class="pre">UNAVAILABLE_FOR_LEGAL_REASONS</span></code></p></td>
  424. <td><p>An HTTP Status Code to Report Legal Obstacles <span class="target" id="index-51"></span><a class="rfc reference external" href="https://datatracker.ietf.org/doc/html/rfc7725.html"><strong>RFC 7725</strong></a></p></td>
  425. </tr>
  426. <tr class="row-odd"><td><p><code class="docutils literal notranslate"><span class="pre">500</span></code></p></td>
  427. <td><p><code class="docutils literal notranslate"><span class="pre">INTERNAL_SERVER_ERROR</span></code></p></td>
  428. <td><p>HTTP/1.1 <span class="target" id="index-52"></span><a class="rfc reference external" href="https://datatracker.ietf.org/doc/html/rfc7231.html"><strong>RFC 7231</strong></a>, Section 6.6.1</p></td>
  429. </tr>
  430. <tr class="row-even"><td><p><code class="docutils literal notranslate"><span class="pre">501</span></code></p></td>
  431. <td><p><code class="docutils literal notranslate"><span class="pre">NOT_IMPLEMENTED</span></code></p></td>
  432. <td><p>HTTP/1.1 <span class="target" id="index-53"></span><a class="rfc reference external" href="https://datatracker.ietf.org/doc/html/rfc7231.html"><strong>RFC 7231</strong></a>, Section 6.6.2</p></td>
  433. </tr>
  434. <tr class="row-odd"><td><p><code class="docutils literal notranslate"><span class="pre">502</span></code></p></td>
  435. <td><p><code class="docutils literal notranslate"><span class="pre">BAD_GATEWAY</span></code></p></td>
  436. <td><p>HTTP/1.1 <span class="target" id="index-54"></span><a class="rfc reference external" href="https://datatracker.ietf.org/doc/html/rfc7231.html"><strong>RFC 7231</strong></a>, Section 6.6.3</p></td>
  437. </tr>
  438. <tr class="row-even"><td><p><code class="docutils literal notranslate"><span class="pre">503</span></code></p></td>
  439. <td><p><code class="docutils literal notranslate"><span class="pre">SERVICE_UNAVAILABLE</span></code></p></td>
  440. <td><p>HTTP/1.1 <span class="target" id="index-55"></span><a class="rfc reference external" href="https://datatracker.ietf.org/doc/html/rfc7231.html"><strong>RFC 7231</strong></a>, Section 6.6.4</p></td>
  441. </tr>
  442. <tr class="row-odd"><td><p><code class="docutils literal notranslate"><span class="pre">504</span></code></p></td>
  443. <td><p><code class="docutils literal notranslate"><span class="pre">GATEWAY_TIMEOUT</span></code></p></td>
  444. <td><p>HTTP/1.1 <span class="target" id="index-56"></span><a class="rfc reference external" href="https://datatracker.ietf.org/doc/html/rfc7231.html"><strong>RFC 7231</strong></a>, Section 6.6.5</p></td>
  445. </tr>
  446. <tr class="row-even"><td><p><code class="docutils literal notranslate"><span class="pre">505</span></code></p></td>
  447. <td><p><code class="docutils literal notranslate"><span class="pre">HTTP_VERSION_NOT_SUPPORTED</span></code></p></td>
  448. <td><p>HTTP/1.1 <span class="target" id="index-57"></span><a class="rfc reference external" href="https://datatracker.ietf.org/doc/html/rfc7231.html"><strong>RFC 7231</strong></a>, Section 6.6.6</p></td>
  449. </tr>
  450. <tr class="row-odd"><td><p><code class="docutils literal notranslate"><span class="pre">506</span></code></p></td>
  451. <td><p><code class="docutils literal notranslate"><span class="pre">VARIANT_ALSO_NEGOTIATES</span></code></p></td>
  452. <td><p>Transparent Content Negotiation in HTTP <span class="target" id="index-58"></span><a class="rfc reference external" href="https://datatracker.ietf.org/doc/html/rfc2295.html"><strong>RFC 2295</strong></a>, Section 8.1 (Experimental)</p></td>
  453. </tr>
  454. <tr class="row-even"><td><p><code class="docutils literal notranslate"><span class="pre">507</span></code></p></td>
  455. <td><p><code class="docutils literal notranslate"><span class="pre">INSUFFICIENT_STORAGE</span></code></p></td>
  456. <td><p>WebDAV <span class="target" id="index-59"></span><a class="rfc reference external" href="https://datatracker.ietf.org/doc/html/rfc4918.html"><strong>RFC 4918</strong></a>, Section 11.5</p></td>
  457. </tr>
  458. <tr class="row-odd"><td><p><code class="docutils literal notranslate"><span class="pre">508</span></code></p></td>
  459. <td><p><code class="docutils literal notranslate"><span class="pre">LOOP_DETECTED</span></code></p></td>
  460. <td><p>WebDAV Binding Extensions <span class="target" id="index-60"></span><a class="rfc reference external" href="https://datatracker.ietf.org/doc/html/rfc5842.html"><strong>RFC 5842</strong></a>, Section 7.2 (Experimental)</p></td>
  461. </tr>
  462. <tr class="row-even"><td><p><code class="docutils literal notranslate"><span class="pre">510</span></code></p></td>
  463. <td><p><code class="docutils literal notranslate"><span class="pre">NOT_EXTENDED</span></code></p></td>
  464. <td><p>An HTTP Extension Framework <span class="target" id="index-61"></span><a class="rfc reference external" href="https://datatracker.ietf.org/doc/html/rfc2774.html"><strong>RFC 2774</strong></a>, Section 7 (Experimental)</p></td>
  465. </tr>
  466. <tr class="row-odd"><td><p><code class="docutils literal notranslate"><span class="pre">511</span></code></p></td>
  467. <td><p><code class="docutils literal notranslate"><span class="pre">NETWORK_AUTHENTICATION_REQUIRED</span></code></p></td>
  468. <td><p>Additional HTTP Status Codes <span class="target" id="index-62"></span><a class="rfc reference external" href="https://datatracker.ietf.org/doc/html/rfc6585.html"><strong>RFC 6585</strong></a>, Section 6</p></td>
  469. </tr>
  470. </tbody>
  471. </table>
  472. <p>In order to preserve backwards compatibility, enum values are also present
  473. in the <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> module in the form of constants. The enum name is
  474. equal to the constant name (i.e. <code class="docutils literal notranslate"><span class="pre">http.HTTPStatus.OK</span></code> is also available as
  475. <code class="docutils literal notranslate"><span class="pre">http.client.OK</span></code>).</p>
  476. <div class="versionchanged">
  477. <p><span class="versionmodified changed">Changed in version 3.7: </span>Added <code class="docutils literal notranslate"><span class="pre">421</span> <span class="pre">MISDIRECTED_REQUEST</span></code> status code.</p>
  478. </div>
  479. <div class="versionadded">
  480. <p><span class="versionmodified added">New in version 3.8: </span>Added <code class="docutils literal notranslate"><span class="pre">451</span> <span class="pre">UNAVAILABLE_FOR_LEGAL_REASONS</span></code> status code.</p>
  481. </div>
  482. <div class="versionadded">
  483. <p><span class="versionmodified added">New in version 3.9: </span>Added <code class="docutils literal notranslate"><span class="pre">103</span> <span class="pre">EARLY_HINTS</span></code>, <code class="docutils literal notranslate"><span class="pre">418</span> <span class="pre">IM_A_TEAPOT</span></code> and <code class="docutils literal notranslate"><span class="pre">425</span> <span class="pre">TOO_EARLY</span></code> status codes.</p>
  484. </div>
  485. </section>
  486. <section id="http-status-category">
  487. <h2>HTTP status category<a class="headerlink" href="#http-status-category" title="Link to this heading">¶</a></h2>
  488. <div class="versionadded">
  489. <p><span class="versionmodified added">New in version 3.12.</span></p>
  490. </div>
  491. <p>The enum values have several properties to indicate the HTTP status category:</p>
  492. <table class="docutils align-default">
  493. <thead>
  494. <tr class="row-odd"><th class="head"><p>Property</p></th>
  495. <th class="head"><p>Indicates that</p></th>
  496. <th class="head"><p>Details</p></th>
  497. </tr>
  498. </thead>
  499. <tbody>
  500. <tr class="row-even"><td><p><code class="docutils literal notranslate"><span class="pre">is_informational</span></code></p></td>
  501. <td><p><code class="docutils literal notranslate"><span class="pre">100</span> <span class="pre">&lt;=</span> <span class="pre">status</span> <span class="pre">&lt;=</span> <span class="pre">199</span></code></p></td>
  502. <td><p>HTTP/1.1 <span class="target" id="index-63"></span><a class="rfc reference external" href="https://datatracker.ietf.org/doc/html/rfc7231.html"><strong>RFC 7231</strong></a>, Section 6</p></td>
  503. </tr>
  504. <tr class="row-odd"><td><p><code class="docutils literal notranslate"><span class="pre">is_success</span></code></p></td>
  505. <td><p><code class="docutils literal notranslate"><span class="pre">200</span> <span class="pre">&lt;=</span> <span class="pre">status</span> <span class="pre">&lt;=</span> <span class="pre">299</span></code></p></td>
  506. <td><p>HTTP/1.1 <span class="target" id="index-64"></span><a class="rfc reference external" href="https://datatracker.ietf.org/doc/html/rfc7231.html"><strong>RFC 7231</strong></a>, Section 6</p></td>
  507. </tr>
  508. <tr class="row-even"><td><p><code class="docutils literal notranslate"><span class="pre">is_redirection</span></code></p></td>
  509. <td><p><code class="docutils literal notranslate"><span class="pre">300</span> <span class="pre">&lt;=</span> <span class="pre">status</span> <span class="pre">&lt;=</span> <span class="pre">399</span></code></p></td>
  510. <td><p>HTTP/1.1 <span class="target" id="index-65"></span><a class="rfc reference external" href="https://datatracker.ietf.org/doc/html/rfc7231.html"><strong>RFC 7231</strong></a>, Section 6</p></td>
  511. </tr>
  512. <tr class="row-odd"><td><p><code class="docutils literal notranslate"><span class="pre">is_client_error</span></code></p></td>
  513. <td><p><code class="docutils literal notranslate"><span class="pre">400</span> <span class="pre">&lt;=</span> <span class="pre">status</span> <span class="pre">&lt;=</span> <span class="pre">499</span></code></p></td>
  514. <td><p>HTTP/1.1 <span class="target" id="index-66"></span><a class="rfc reference external" href="https://datatracker.ietf.org/doc/html/rfc7231.html"><strong>RFC 7231</strong></a>, Section 6</p></td>
  515. </tr>
  516. <tr class="row-even"><td><p><code class="docutils literal notranslate"><span class="pre">is_server_error</span></code></p></td>
  517. <td><p><code class="docutils literal notranslate"><span class="pre">500</span> <span class="pre">&lt;=</span> <span class="pre">status</span> <span class="pre">&lt;=</span> <span class="pre">599</span></code></p></td>
  518. <td><p>HTTP/1.1 <span class="target" id="index-67"></span><a class="rfc reference external" href="https://datatracker.ietf.org/doc/html/rfc7231.html"><strong>RFC 7231</strong></a>, Section 6</p></td>
  519. </tr>
  520. </tbody>
  521. </table>
  522. <blockquote>
  523. <div><p>Usage:</p>
  524. <div class="highlight-python3 notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">http</span> <span class="kn">import</span> <span class="n">HTTPStatus</span>
  525. <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">is_success</span>
  526. <span class="go">True</span>
  527. <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">is_client_error</span>
  528. <span class="go">False</span>
  529. </pre></div>
  530. </div>
  531. </div></blockquote>
  532. <dl class="py class">
  533. <dt class="sig sig-object py" id="http.HTTPMethod">
  534. <em class="property"><span class="pre">class</span><span class="w"> </span></em><span class="sig-prename descclassname"><span class="pre">http.</span></span><span class="sig-name descname"><span class="pre">HTTPMethod</span></span><a class="headerlink" href="#http.HTTPMethod" title="Link to this definition">¶</a></dt>
  535. <dd><div class="versionadded">
  536. <p><span class="versionmodified added">New in version 3.11.</span></p>
  537. </div>
  538. <p>A subclass of <a class="reference internal" href="enum.html#enum.StrEnum" title="enum.StrEnum"><code class="xref py py-class docutils literal notranslate"><span class="pre">enum.StrEnum</span></code></a> that defines a set of HTTP methods and descriptions written in English.</p>
  539. <p>Usage:</p>
  540. <div class="highlight-python3 notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">http</span> <span class="kn">import</span> <span class="n">HTTPMethod</span>
  541. <span class="gp">&gt;&gt;&gt;</span>
  542. <span class="gp">&gt;&gt;&gt; </span><span class="n">HTTPMethod</span><span class="o">.</span><span class="n">GET</span>
  543. <span class="go">&lt;HTTPMethod.GET&gt;</span>
  544. <span class="gp">&gt;&gt;&gt; </span><span class="n">HTTPMethod</span><span class="o">.</span><span class="n">GET</span> <span class="o">==</span> <span class="s1">&#39;GET&#39;</span>
  545. <span class="go">True</span>
  546. <span class="gp">&gt;&gt;&gt; </span><span class="n">HTTPMethod</span><span class="o">.</span><span class="n">GET</span><span class="o">.</span><span class="n">value</span>
  547. <span class="go">&#39;GET&#39;</span>
  548. <span class="gp">&gt;&gt;&gt; </span><span class="n">HTTPMethod</span><span class="o">.</span><span class="n">GET</span><span class="o">.</span><span class="n">description</span>
  549. <span class="go">&#39;Retrieve the target.&#39;</span>
  550. <span class="gp">&gt;&gt;&gt; </span><span class="nb">list</span><span class="p">(</span><span class="n">HTTPMethod</span><span class="p">)</span>
  551. <span class="go">[&lt;HTTPMethod.CONNECT&gt;,</span>
  552. <span class="go"> &lt;HTTPMethod.DELETE&gt;,</span>
  553. <span class="go"> &lt;HTTPMethod.GET&gt;,</span>
  554. <span class="go"> &lt;HTTPMethod.HEAD&gt;,</span>
  555. <span class="go"> &lt;HTTPMethod.OPTIONS&gt;,</span>
  556. <span class="go"> &lt;HTTPMethod.PATCH&gt;,</span>
  557. <span class="go"> &lt;HTTPMethod.POST&gt;,</span>
  558. <span class="go"> &lt;HTTPMethod.PUT&gt;,</span>
  559. <span class="go"> &lt;HTTPMethod.TRACE&gt;]</span>
  560. </pre></div>
  561. </div>
  562. </dd></dl>
  563. </section>
  564. <section id="http-methods">
  565. <span id="id2"></span><h2>HTTP methods<a class="headerlink" href="#http-methods" title="Link to this heading">¶</a></h2>
  566. <p>Supported,
  567. <a class="reference external" href="https://www.iana.org/assignments/http-methods/http-methods.xhtml">IANA-registered methods</a>
  568. available in <a class="reference internal" href="#http.HTTPMethod" title="http.HTTPMethod"><code class="xref py py-class docutils literal notranslate"><span class="pre">http.HTTPMethod</span></code></a> are:</p>
  569. <table class="docutils align-default">
  570. <thead>
  571. <tr class="row-odd"><th class="head"><p>Method</p></th>
  572. <th class="head"><p>Enum Name</p></th>
  573. <th class="head"><p>Details</p></th>
  574. </tr>
  575. </thead>
  576. <tbody>
  577. <tr class="row-even"><td><p><code class="docutils literal notranslate"><span class="pre">GET</span></code></p></td>
  578. <td><p><code class="docutils literal notranslate"><span class="pre">GET</span></code></p></td>
  579. <td><p>HTTP/1.1 <span class="target" id="index-68"></span><a class="rfc reference external" href="https://datatracker.ietf.org/doc/html/rfc7231.html"><strong>RFC 7231</strong></a>, Section 4.3.1</p></td>
  580. </tr>
  581. <tr class="row-odd"><td><p><code class="docutils literal notranslate"><span class="pre">HEAD</span></code></p></td>
  582. <td><p><code class="docutils literal notranslate"><span class="pre">HEAD</span></code></p></td>
  583. <td><p>HTTP/1.1 <span class="target" id="index-69"></span><a class="rfc reference external" href="https://datatracker.ietf.org/doc/html/rfc7231.html"><strong>RFC 7231</strong></a>, Section 4.3.2</p></td>
  584. </tr>
  585. <tr class="row-even"><td><p><code class="docutils literal notranslate"><span class="pre">POST</span></code></p></td>
  586. <td><p><code class="docutils literal notranslate"><span class="pre">POST</span></code></p></td>
  587. <td><p>HTTP/1.1 <span class="target" id="index-70"></span><a class="rfc reference external" href="https://datatracker.ietf.org/doc/html/rfc7231.html"><strong>RFC 7231</strong></a>, Section 4.3.3</p></td>
  588. </tr>
  589. <tr class="row-odd"><td><p><code class="docutils literal notranslate"><span class="pre">PUT</span></code></p></td>
  590. <td><p><code class="docutils literal notranslate"><span class="pre">PUT</span></code></p></td>
  591. <td><p>HTTP/1.1 <span class="target" id="index-71"></span><a class="rfc reference external" href="https://datatracker.ietf.org/doc/html/rfc7231.html"><strong>RFC 7231</strong></a>, Section 4.3.4</p></td>
  592. </tr>
  593. <tr class="row-even"><td><p><code class="docutils literal notranslate"><span class="pre">DELETE</span></code></p></td>
  594. <td><p><code class="docutils literal notranslate"><span class="pre">DELETE</span></code></p></td>
  595. <td><p>HTTP/1.1 <span class="target" id="index-72"></span><a class="rfc reference external" href="https://datatracker.ietf.org/doc/html/rfc7231.html"><strong>RFC 7231</strong></a>, Section 4.3.5</p></td>
  596. </tr>
  597. <tr class="row-odd"><td><p><code class="docutils literal notranslate"><span class="pre">CONNECT</span></code></p></td>
  598. <td><p><code class="docutils literal notranslate"><span class="pre">CONNECT</span></code></p></td>
  599. <td><p>HTTP/1.1 <span class="target" id="index-73"></span><a class="rfc reference external" href="https://datatracker.ietf.org/doc/html/rfc7231.html"><strong>RFC 7231</strong></a>, Section 4.3.6</p></td>
  600. </tr>
  601. <tr class="row-even"><td><p><code class="docutils literal notranslate"><span class="pre">OPTIONS</span></code></p></td>
  602. <td><p><code class="docutils literal notranslate"><span class="pre">OPTIONS</span></code></p></td>
  603. <td><p>HTTP/1.1 <span class="target" id="index-74"></span><a class="rfc reference external" href="https://datatracker.ietf.org/doc/html/rfc7231.html"><strong>RFC 7231</strong></a>, Section 4.3.7</p></td>
  604. </tr>
  605. <tr class="row-odd"><td><p><code class="docutils literal notranslate"><span class="pre">TRACE</span></code></p></td>
  606. <td><p><code class="docutils literal notranslate"><span class="pre">TRACE</span></code></p></td>
  607. <td><p>HTTP/1.1 <span class="target" id="index-75"></span><a class="rfc reference external" href="https://datatracker.ietf.org/doc/html/rfc7231.html"><strong>RFC 7231</strong></a>, Section 4.3.8</p></td>
  608. </tr>
  609. <tr class="row-even"><td><p><code class="docutils literal notranslate"><span class="pre">PATCH</span></code></p></td>
  610. <td><p><code class="docutils literal notranslate"><span class="pre">PATCH</span></code></p></td>
  611. <td><p>HTTP/1.1 <span class="target" id="index-76"></span><a class="rfc reference external" href="https://datatracker.ietf.org/doc/html/rfc5789.html"><strong>RFC 5789</strong></a></p></td>
  612. </tr>
  613. </tbody>
  614. </table>
  615. </section>
  616. </section>
  617. <div class="clearer"></div>
  618. </div>
  619. </div>
  620. </div>
  621. <div class="sphinxsidebar" role="navigation" aria-label="main navigation">
  622. <div class="sphinxsidebarwrapper">
  623. <div>
  624. <h3><a href="../contents.html">Table of Contents</a></h3>
  625. <ul>
  626. <li><a class="reference internal" href="#"><code class="xref py py-mod docutils literal notranslate"><span class="pre">http</span></code> — HTTP modules</a><ul>
  627. <li><a class="reference internal" href="#http-status-codes">HTTP status codes</a></li>
  628. <li><a class="reference internal" href="#http-status-category">HTTP status category</a></li>
  629. <li><a class="reference internal" href="#http-methods">HTTP methods</a></li>
  630. </ul>
  631. </li>
  632. </ul>
  633. </div>
  634. <div>
  635. <h4>Previous topic</h4>
  636. <p class="topless"><a href="urllib.robotparser.html"
  637. title="previous chapter"><code class="xref py py-mod docutils literal notranslate"><span class="pre">urllib.robotparser</span></code> — Parser for robots.txt</a></p>
  638. </div>
  639. <div>
  640. <h4>Next topic</h4>
  641. <p class="topless"><a href="http.client.html"
  642. title="next chapter"><code class="xref py py-mod docutils literal notranslate"><span class="pre">http.client</span></code> — HTTP protocol client</a></p>
  643. </div>
  644. <div role="note" aria-label="source link">
  645. <h3>This Page</h3>
  646. <ul class="this-page-menu">
  647. <li><a href="../bugs.html">Report a Bug</a></li>
  648. <li>
  649. <a href="https://github.com/python/cpython/blob/main/Doc/library/http.rst"
  650. rel="nofollow">Show Source
  651. </a>
  652. </li>
  653. </ul>
  654. </div>
  655. </div>
  656. <div id="sidebarbutton" title="Collapse sidebar">
  657. <span>«</span>
  658. </div>
  659. </div>
  660. <div class="clearer"></div>
  661. </div>
  662. <div class="related" role="navigation" aria-label="related navigation">
  663. <h3>Navigation</h3>
  664. <ul>
  665. <li class="right" style="margin-right: 10px">
  666. <a href="../genindex.html" title="General Index"
  667. >index</a></li>
  668. <li class="right" >
  669. <a href="../py-modindex.html" title="Python Module Index"
  670. >modules</a> |</li>
  671. <li class="right" >
  672. <a href="http.client.html" title="http.client — HTTP protocol client"
  673. >next</a> |</li>
  674. <li class="right" >
  675. <a href="urllib.robotparser.html" title="urllib.robotparser — Parser for robots.txt"
  676. >previous</a> |</li>
  677. <li><img src="../_static/py.svg" alt="Python logo" style="vertical-align: middle; margin-top: -1px"/></li>
  678. <li><a href="https://www.python.org/">Python</a> &#187;</li>
  679. <li class="switchers">
  680. <div class="language_switcher_placeholder"></div>
  681. <div class="version_switcher_placeholder"></div>
  682. </li>
  683. <li>
  684. </li>
  685. <li id="cpython-language-and-version">
  686. <a href="../index.html">3.12.3 Documentation</a> &#187;
  687. </li>
  688. <li class="nav-item nav-item-1"><a href="index.html" >The Python Standard Library</a> &#187;</li>
  689. <li class="nav-item nav-item-2"><a href="internet.html" >Internet Protocols and Support</a> &#187;</li>
  690. <li class="nav-item nav-item-this"><a href=""><code class="xref py py-mod docutils literal notranslate"><span class="pre">http</span></code> — HTTP modules</a></li>
  691. <li class="right">
  692. <div class="inline-search" role="search">
  693. <form class="inline-search" action="../search.html" method="get">
  694. <input placeholder="Quick search" aria-label="Quick search" type="search" name="q" id="search-box" />
  695. <input type="submit" value="Go" />
  696. </form>
  697. </div>
  698. |
  699. </li>
  700. <li class="right">
  701. <label class="theme-selector-label">
  702. Theme
  703. <select class="theme-selector" oninput="activateTheme(this.value)">
  704. <option value="auto" selected>Auto</option>
  705. <option value="light">Light</option>
  706. <option value="dark">Dark</option>
  707. </select>
  708. </label> |</li>
  709. </ul>
  710. </div>
  711. <div class="footer">
  712. &copy;
  713. <a href="../copyright.html">
  714. Copyright
  715. </a>
  716. 2001-2024, Python Software Foundation.
  717. <br />
  718. This page is licensed under the Python Software Foundation License Version 2.
  719. <br />
  720. Examples, recipes, and other code in the documentation are additionally licensed under the Zero Clause BSD License.
  721. <br />
  722. See <a href="/license.html">History and License</a> for more information.<br />
  723. <br />
  724. The Python Software Foundation is a non-profit corporation.
  725. <a href="https://www.python.org/psf/donations/">Please donate.</a>
  726. <br />
  727. <br />
  728. Last updated on Apr 09, 2024 (13:47 UTC).
  729. <a href="/bugs.html">Found a bug</a>?
  730. <br />
  731. Created using <a href="https://www.sphinx-doc.org/">Sphinx</a> 7.2.6.
  732. </div>
  733. </body>
  734. </html>
上海开阖软件有限公司 沪ICP备12045867号-1