summaryrefslogtreecommitdiff
path: root/devdocs/python~3.12/library%2Fhttp.html
blob: 3110789551878db2ef81cdad468b900faa0e2c85 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
 <span id="http-http-modules"></span><h1>http — HTTP modules</h1> <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>  <p><a class="reference internal" href="#module-http" title="http: HTTP status codes and messages"><code>http</code></a> is a package that collects several modules for working with the HyperText Transfer Protocol:</p> <ul class="simple"> <li>
<a class="reference internal" href="http.client#module-http.client" title="http.client: HTTP and HTTPS protocol client (requires sockets)."><code>http.client</code></a> is a low-level HTTP protocol client; for high-level URL opening use <a class="reference internal" href="urllib.request#module-urllib.request" title="urllib.request: Extensible library for opening URLs."><code>urllib.request</code></a>
</li> <li>
<a class="reference internal" href="http.server#module-http.server" title="http.server: HTTP server and request handlers."><code>http.server</code></a> contains basic HTTP server classes based on <a class="reference internal" href="socketserver#module-socketserver" title="socketserver: A framework for network servers."><code>socketserver</code></a>
</li> <li>
<a class="reference internal" href="http.cookies#module-http.cookies" title="http.cookies: Support for HTTP state management (cookies)."><code>http.cookies</code></a> has utilities for implementing state management with cookies</li> <li>
<a class="reference internal" href="http.cookiejar#module-http.cookiejar" title="http.cookiejar: Classes for automatic handling of HTTP cookies."><code>http.cookiejar</code></a> provides persistence of cookies</li> </ul> <p>The <a class="reference internal" href="#module-http" title="http: HTTP status codes and messages"><code>http</code></a> module also defines the following enums that help you work with http related code:</p> <dl class="py class"> <dt class="sig sig-object py" id="http.HTTPStatus">
<code>class http.HTTPStatus</code> </dt> <dd>
<div class="versionadded"> <p><span class="versionmodified added">New in version 3.5.</span></p> </div> <p>A subclass of <a class="reference internal" href="enum#enum.IntEnum" title="enum.IntEnum"><code>enum.IntEnum</code></a> that defines a set of HTTP status codes, reason phrases and long descriptions written in English.</p> <p>Usage:</p> <pre data-language="python">&gt;&gt;&gt; from http import HTTPStatus
&gt;&gt;&gt; HTTPStatus.OK
HTTPStatus.OK
&gt;&gt;&gt; HTTPStatus.OK == 200
True
&gt;&gt;&gt; HTTPStatus.OK.value
200
&gt;&gt;&gt; HTTPStatus.OK.phrase
'OK'
&gt;&gt;&gt; HTTPStatus.OK.description
'Request fulfilled, document follows'
&gt;&gt;&gt; list(HTTPStatus)
[HTTPStatus.CONTINUE, HTTPStatus.SWITCHING_PROTOCOLS, ...]
</pre> </dd>
</dl> <section id="http-status-codes"> <span id="id1"></span><h2>HTTP status codes</h2> <p>Supported, <a class="reference external" href="https://www.iana.org/assignments/http-status-codes/http-status-codes.xhtml">IANA-registered status codes</a> available in <a class="reference internal" href="#http.HTTPStatus" title="http.HTTPStatus"><code>http.HTTPStatus</code></a> are:</p> <table class="docutils align-default">  <thead> <tr>
<th class="head"><p>Code</p></th> <th class="head"><p>Enum Name</p></th> <th class="head"><p>Details</p></th> </tr> </thead>  <tr>
<td><p><code>100</code></p></td> <td><p><code>CONTINUE</code></p></td> <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> </tr> <tr>
<td><p><code>101</code></p></td> <td><p><code>SWITCHING_PROTOCOLS</code></p></td> <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> </tr> <tr>
<td><p><code>102</code></p></td> <td><p><code>PROCESSING</code></p></td> <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> </tr> <tr>
<td><p><code>103</code></p></td> <td><p><code>EARLY_HINTS</code></p></td> <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> </tr> <tr>
<td><p><code>200</code></p></td> <td><p><code>OK</code></p></td> <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> </tr> <tr>
<td><p><code>201</code></p></td> <td><p><code>CREATED</code></p></td> <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> </tr> <tr>
<td><p><code>202</code></p></td> <td><p><code>ACCEPTED</code></p></td> <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> </tr> <tr>
<td><p><code>203</code></p></td> <td><p><code>NON_AUTHORITATIVE_INFORMATION</code></p></td> <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> </tr> <tr>
<td><p><code>204</code></p></td> <td><p><code>NO_CONTENT</code></p></td> <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> </tr> <tr>
<td><p><code>205</code></p></td> <td><p><code>RESET_CONTENT</code></p></td> <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> </tr> <tr>
<td><p><code>206</code></p></td> <td><p><code>PARTIAL_CONTENT</code></p></td> <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> </tr> <tr>
<td><p><code>207</code></p></td> <td><p><code>MULTI_STATUS</code></p></td> <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> </tr> <tr>
<td><p><code>208</code></p></td> <td><p><code>ALREADY_REPORTED</code></p></td> <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> </tr> <tr>
<td><p><code>226</code></p></td> <td><p><code>IM_USED</code></p></td> <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> </tr> <tr>
<td><p><code>300</code></p></td> <td><p><code>MULTIPLE_CHOICES</code></p></td> <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> </tr> <tr>
<td><p><code>301</code></p></td> <td><p><code>MOVED_PERMANENTLY</code></p></td> <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> </tr> <tr>
<td><p><code>302</code></p></td> <td><p><code>FOUND</code></p></td> <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> </tr> <tr>
<td><p><code>303</code></p></td> <td><p><code>SEE_OTHER</code></p></td> <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> </tr> <tr>
<td><p><code>304</code></p></td> <td><p><code>NOT_MODIFIED</code></p></td> <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> </tr> <tr>
<td><p><code>305</code></p></td> <td><p><code>USE_PROXY</code></p></td> <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> </tr> <tr>
<td><p><code>307</code></p></td> <td><p><code>TEMPORARY_REDIRECT</code></p></td> <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> </tr> <tr>
<td><p><code>308</code></p></td> <td><p><code>PERMANENT_REDIRECT</code></p></td> <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> </tr> <tr>
<td><p><code>400</code></p></td> <td><p><code>BAD_REQUEST</code></p></td> <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> </tr> <tr>
<td><p><code>401</code></p></td> <td><p><code>UNAUTHORIZED</code></p></td> <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> </tr> <tr>
<td><p><code>402</code></p></td> <td><p><code>PAYMENT_REQUIRED</code></p></td> <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> </tr> <tr>
<td><p><code>403</code></p></td> <td><p><code>FORBIDDEN</code></p></td> <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> </tr> <tr>
<td><p><code>404</code></p></td> <td><p><code>NOT_FOUND</code></p></td> <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> </tr> <tr>
<td><p><code>405</code></p></td> <td><p><code>METHOD_NOT_ALLOWED</code></p></td> <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> </tr> <tr>
<td><p><code>406</code></p></td> <td><p><code>NOT_ACCEPTABLE</code></p></td> <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> </tr> <tr>
<td><p><code>407</code></p></td> <td><p><code>PROXY_AUTHENTICATION_REQUIRED</code></p></td> <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> </tr> <tr>
<td><p><code>408</code></p></td> <td><p><code>REQUEST_TIMEOUT</code></p></td> <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> </tr> <tr>
<td><p><code>409</code></p></td> <td><p><code>CONFLICT</code></p></td> <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> </tr> <tr>
<td><p><code>410</code></p></td> <td><p><code>GONE</code></p></td> <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> </tr> <tr>
<td><p><code>411</code></p></td> <td><p><code>LENGTH_REQUIRED</code></p></td> <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> </tr> <tr>
<td><p><code>412</code></p></td> <td><p><code>PRECONDITION_FAILED</code></p></td> <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> </tr> <tr>
<td><p><code>413</code></p></td> <td><p><code>REQUEST_ENTITY_TOO_LARGE</code></p></td> <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> </tr> <tr>
<td><p><code>414</code></p></td> <td><p><code>REQUEST_URI_TOO_LONG</code></p></td> <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> </tr> <tr>
<td><p><code>415</code></p></td> <td><p><code>UNSUPPORTED_MEDIA_TYPE</code></p></td> <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> </tr> <tr>
<td><p><code>416</code></p></td> <td><p><code>REQUESTED_RANGE_NOT_SATISFIABLE</code></p></td> <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> </tr> <tr>
<td><p><code>417</code></p></td> <td><p><code>EXPECTATION_FAILED</code></p></td> <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> </tr> <tr>
<td><p><code>418</code></p></td> <td><p><code>IM_A_TEAPOT</code></p></td> <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> </tr> <tr>
<td><p><code>421</code></p></td> <td><p><code>MISDIRECTED_REQUEST</code></p></td> <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> </tr> <tr>
<td><p><code>422</code></p></td> <td><p><code>UNPROCESSABLE_ENTITY</code></p></td> <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> </tr> <tr>
<td><p><code>423</code></p></td> <td><p><code>LOCKED</code></p></td> <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> </tr> <tr>
<td><p><code>424</code></p></td> <td><p><code>FAILED_DEPENDENCY</code></p></td> <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> </tr> <tr>
<td><p><code>425</code></p></td> <td><p><code>TOO_EARLY</code></p></td> <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> </tr> <tr>
<td><p><code>426</code></p></td> <td><p><code>UPGRADE_REQUIRED</code></p></td> <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> </tr> <tr>
<td><p><code>428</code></p></td> <td><p><code>PRECONDITION_REQUIRED</code></p></td> <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> </tr> <tr>
<td><p><code>429</code></p></td> <td><p><code>TOO_MANY_REQUESTS</code></p></td> <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> </tr> <tr>
<td><p><code>431</code></p></td> <td><p><code>REQUEST_HEADER_FIELDS_TOO_LARGE</code></p></td> <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> </tr> <tr>
<td><p><code>451</code></p></td> <td><p><code>UNAVAILABLE_FOR_LEGAL_REASONS</code></p></td> <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> </tr> <tr>
<td><p><code>500</code></p></td> <td><p><code>INTERNAL_SERVER_ERROR</code></p></td> <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> </tr> <tr>
<td><p><code>501</code></p></td> <td><p><code>NOT_IMPLEMENTED</code></p></td> <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> </tr> <tr>
<td><p><code>502</code></p></td> <td><p><code>BAD_GATEWAY</code></p></td> <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> </tr> <tr>
<td><p><code>503</code></p></td> <td><p><code>SERVICE_UNAVAILABLE</code></p></td> <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> </tr> <tr>
<td><p><code>504</code></p></td> <td><p><code>GATEWAY_TIMEOUT</code></p></td> <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> </tr> <tr>
<td><p><code>505</code></p></td> <td><p><code>HTTP_VERSION_NOT_SUPPORTED</code></p></td> <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> </tr> <tr>
<td><p><code>506</code></p></td> <td><p><code>VARIANT_ALSO_NEGOTIATES</code></p></td> <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> </tr> <tr>
<td><p><code>507</code></p></td> <td><p><code>INSUFFICIENT_STORAGE</code></p></td> <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> </tr> <tr>
<td><p><code>508</code></p></td> <td><p><code>LOOP_DETECTED</code></p></td> <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> </tr> <tr>
<td><p><code>510</code></p></td> <td><p><code>NOT_EXTENDED</code></p></td> <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> </tr> <tr>
<td><p><code>511</code></p></td> <td><p><code>NETWORK_AUTHENTICATION_REQUIRED</code></p></td> <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> </tr>  </table> <p>In order to preserve backwards compatibility, enum values are also present in the <a class="reference internal" href="http.client#module-http.client" title="http.client: HTTP and HTTPS protocol client (requires sockets)."><code>http.client</code></a> module in the form of constants. The enum name is equal to the constant name (i.e. <code>http.HTTPStatus.OK</code> is also available as <code>http.client.OK</code>).</p> <div class="versionchanged"> <p><span class="versionmodified changed">Changed in version 3.7: </span>Added <code>421 MISDIRECTED_REQUEST</code> status code.</p> </div> <div class="versionadded"> <p><span class="versionmodified added">New in version 3.8: </span>Added <code>451 UNAVAILABLE_FOR_LEGAL_REASONS</code> status code.</p> </div> <div class="versionadded"> <p><span class="versionmodified added">New in version 3.9: </span>Added <code>103 EARLY_HINTS</code>, <code>418 IM_A_TEAPOT</code> and <code>425 TOO_EARLY</code> status codes.</p> </div> </section> <section id="http-status-category"> <h2>HTTP status category</h2> <div class="versionadded"> <p><span class="versionmodified added">New in version 3.12.</span></p> </div> <p>The enum values have several properties to indicate the HTTP status category:</p> <table class="docutils align-default">  <thead> <tr>
<th class="head"><p>Property</p></th> <th class="head"><p>Indicates that</p></th> <th class="head"><p>Details</p></th> </tr> </thead>  <tr>
<td><p><code>is_informational</code></p></td> <td><p><code>100 &lt;= status &lt;= 199</code></p></td> <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> </tr> <tr>
<td><p><code>is_success</code></p></td> <td><p><code>200 &lt;= status &lt;= 299</code></p></td> <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> </tr> <tr>
<td><p><code>is_redirection</code></p></td> <td><p><code>300 &lt;= status &lt;= 399</code></p></td> <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> </tr> <tr>
<td><p><code>is_client_error</code></p></td> <td><p><code>400 &lt;= status &lt;= 499</code></p></td> <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> </tr> <tr>
<td><p><code>is_server_error</code></p></td> <td><p><code>500 &lt;= status &lt;= 599</code></p></td> <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> </tr>  </table>  <p>Usage:</p> <pre data-language="python">&gt;&gt;&gt; from http import HTTPStatus
&gt;&gt;&gt; HTTPStatus.OK.is_success
True
&gt;&gt;&gt; HTTPStatus.OK.is_client_error
False
</pre>  <dl class="py class"> <dt class="sig sig-object py" id="http.HTTPMethod">
<code>class http.HTTPMethod</code> </dt> <dd>
<div class="versionadded"> <p><span class="versionmodified added">New in version 3.11.</span></p> </div> <p>A subclass of <a class="reference internal" href="enum#enum.StrEnum" title="enum.StrEnum"><code>enum.StrEnum</code></a> that defines a set of HTTP methods and descriptions written in English.</p> <p>Usage:</p> <pre data-language="python">&gt;&gt;&gt; from http import HTTPMethod
&gt;&gt;&gt;
&gt;&gt;&gt; HTTPMethod.GET
&lt;HTTPMethod.GET&gt;
&gt;&gt;&gt; HTTPMethod.GET == 'GET'
True
&gt;&gt;&gt; HTTPMethod.GET.value
'GET'
&gt;&gt;&gt; HTTPMethod.GET.description
'Retrieve the target.'
&gt;&gt;&gt; list(HTTPMethod)
[&lt;HTTPMethod.CONNECT&gt;,
 &lt;HTTPMethod.DELETE&gt;,
 &lt;HTTPMethod.GET&gt;,
 &lt;HTTPMethod.HEAD&gt;,
 &lt;HTTPMethod.OPTIONS&gt;,
 &lt;HTTPMethod.PATCH&gt;,
 &lt;HTTPMethod.POST&gt;,
 &lt;HTTPMethod.PUT&gt;,
 &lt;HTTPMethod.TRACE&gt;]
</pre> </dd>
</dl> </section> <section id="http-methods"> <span id="id2"></span><h2>HTTP methods</h2> <p>Supported, <a class="reference external" href="https://www.iana.org/assignments/http-methods/http-methods.xhtml">IANA-registered methods</a> available in <a class="reference internal" href="#http.HTTPMethod" title="http.HTTPMethod"><code>http.HTTPMethod</code></a> are:</p> <table class="docutils align-default">  <thead> <tr>
<th class="head"><p>Method</p></th> <th class="head"><p>Enum Name</p></th> <th class="head"><p>Details</p></th> </tr> </thead>  <tr>
<td><p><code>GET</code></p></td> <td><p><code>GET</code></p></td> <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> </tr> <tr>
<td><p><code>HEAD</code></p></td> <td><p><code>HEAD</code></p></td> <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> </tr> <tr>
<td><p><code>POST</code></p></td> <td><p><code>POST</code></p></td> <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> </tr> <tr>
<td><p><code>PUT</code></p></td> <td><p><code>PUT</code></p></td> <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> </tr> <tr>
<td><p><code>DELETE</code></p></td> <td><p><code>DELETE</code></p></td> <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> </tr> <tr>
<td><p><code>CONNECT</code></p></td> <td><p><code>CONNECT</code></p></td> <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> </tr> <tr>
<td><p><code>OPTIONS</code></p></td> <td><p><code>OPTIONS</code></p></td> <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> </tr> <tr>
<td><p><code>TRACE</code></p></td> <td><p><code>TRACE</code></p></td> <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> </tr> <tr>
<td><p><code>PATCH</code></p></td> <td><p><code>PATCH</code></p></td> <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> </tr>  </table> </section> <div class="_attribution">
  <p class="_attribution-p">
    &copy; 2001&ndash;2023 Python Software Foundation<br>Licensed under the PSF License.<br>
    <a href="https://docs.python.org/3.12/library/http.html" class="_attribution-link">https://docs.python.org/3.12/library/http.html</a>
  </p>
</div>