@@ -21,8 +21,8 @@ HyperText Transfer Protocol:
21
21
* :mod: `http.cookies ` has utilities for implementing state management with cookies
22
22
* :mod: `http.cookiejar ` provides persistence of cookies
23
23
24
- :mod: ` http ` is also a module that defines a number of HTTP status codes and
25
- associated messages through the :class : `http.HTTPStatus ` enum :
24
+
25
+ The :mod : `http ` module also defines the following enums that help you work with http related code :
26
26
27
27
.. class :: HTTPStatus
28
28
@@ -53,8 +53,8 @@ HTTP status codes
53
53
-----------------
54
54
55
55
Supported,
56
- `IANA-registered <https://www.iana.org/assignments/http-status-codes/http-status-codes.xhtml >`_
57
- status codes available in :class: `http.HTTPStatus ` are:
56
+ `IANA-registered status codes <https://www.iana.org/assignments/http-status-codes/http-status-codes.xhtml >`_
57
+ available in :class: `http.HTTPStatus ` are:
58
58
59
59
======= =================================== ==================================================================
60
60
Code Enum Name Details
@@ -136,3 +136,46 @@ equal to the constant name (i.e. ``http.HTTPStatus.OK`` is also available as
136
136
137
137
.. versionadded :: 3.9
138
138
Added ``103 EARLY_HINTS ``, ``418 IM_A_TEAPOT `` and ``425 TOO_EARLY `` status codes.
139
+
140
+ .. class :: HTTPMethod
141
+
142
+ .. versionadded :: 3.11
143
+
144
+ A subclass of :class: `enum.StrEnum ` that defines a set of HTTP methods and descriptions written in English.
145
+
146
+ Usage::
147
+
148
+ >>> from http import HTTPMethod
149
+ >>> HTTMethod.GET
150
+ HTTMethod.GET
151
+ >>> HTTMethod.GET == 'GET'
152
+ True
153
+ >>> HTTMethod.GET.value
154
+ 'GET'
155
+ >>> HTTMethod.GET.description
156
+ 'Transfer a current representation of the target resource.'
157
+ >>> list(HTTPMethod)
158
+ [HTTPMethod.GET, HTTPMethod.HEAD, ...]
159
+
160
+ .. _http-methods :
161
+
162
+ HTTP methods
163
+ -----------------
164
+
165
+ Supported,
166
+ `IANA-registered methods <https://www.iana.org/assignments/http-methods/http-methods.xhtml >`_
167
+ available in :class: `http.HTTPMethod ` are:
168
+
169
+ =========== =================================== ==================================================================
170
+ Method Enum Name Details
171
+ =========== =================================== ==================================================================
172
+ ``GET `` ``GET `` HTTP/1.1 :rfc: `7231 `, Section 4.3.1
173
+ ``HEAD `` ``HEAD `` HTTP/1.1 :rfc: `7231 `, Section 4.3.2
174
+ ``POST `` ``POST `` HTTP/1.1 :rfc: `7231 `, Section 4.3.3
175
+ ``PUT `` ``PUT `` HTTP/1.1 :rfc: `7231 `, Section 4.3.4
176
+ ``DELETE `` ``DELETE `` HTTP/1.1 :rfc: `7231 `, Section 4.3.5
177
+ ``CONNECT `` ``CONNECT `` HTTP/1.1 :rfc: `7231 `, Section 4.3.6
178
+ ``OPTIONS `` ``OPTIONS `` HTTP/1.1 :rfc: `7231 `, Section 4.3.7
179
+ ``TRACE `` ``TRACE `` HTTP/1.1 :rfc: `7231 `, Section 4.3.8
180
+ ``PATCH `` ``PATCH `` HTTP/1.1 :rfc: `5789 `
181
+ =========== =================================== ==================================================================
0 commit comments