summaryrefslogtreecommitdiffstats
path: root/Doc/library
diff options
context:
space:
mode:
authorAlexandru Mărășteanu <alexei@users.noreply.github.com>2022-08-30 18:11:44 (GMT)
committerGitHub <noreply@github.com>2022-08-30 18:11:44 (GMT)
commit0ed778835d34bc1f39d2c6cdbc0c1709f6bcfd61 (patch)
tree30e5ed320372a5d705b156f6b3eb5de335e575be /Doc/library
parent13c309f1101dc86ca0138f239d45cb009d0e898d (diff)
downloadcpython-0ed778835d34bc1f39d2c6cdbc0c1709f6bcfd61.zip
cpython-0ed778835d34bc1f39d2c6cdbc0c1709f6bcfd61.tar.gz
cpython-0ed778835d34bc1f39d2c6cdbc0c1709f6bcfd61.tar.bz2
gh-95149: Enhance `http.HTTPStatus` with properties that indicate the HTTP status category (GH-95453)
Diffstat (limited to 'Doc/library')
-rw-r--r--Doc/library/http.rst25
1 files changed, 25 insertions, 0 deletions
diff --git a/Doc/library/http.rst b/Doc/library/http.rst
index 5895a41..521fd1b 100644
--- a/Doc/library/http.rst
+++ b/Doc/library/http.rst
@@ -137,6 +137,31 @@ equal to the constant name (i.e. ``http.HTTPStatus.OK`` is also available as
.. versionadded:: 3.9
Added ``103 EARLY_HINTS``, ``418 IM_A_TEAPOT`` and ``425 TOO_EARLY`` status codes.
+HTTP status category
+--------------------
+
+.. versionadded:: 3.11
+
+The enum values have several properties to indicate the HTTP status category:
+
+==================== ======================== ===============================
+Property Indicates that Details
+==================== ======================== ===============================
+``is_informational`` ``100 <= status <= 199`` HTTP/1.1 :rfc:`7231`, Section 6
+``is_success`` ``200 <= status <= 299`` HTTP/1.1 :rfc:`7231`, Section 6
+``is_redirection`` ``300 <= status <= 399`` HTTP/1.1 :rfc:`7231`, Section 6
+``is_client_error`` ``400 <= status <= 499`` HTTP/1.1 :rfc:`7231`, Section 6
+``is_server_error`` ``500 <= status <= 599`` HTTP/1.1 :rfc:`7231`, Section 6
+==================== ======================== ===============================
+
+ Usage::
+
+ >>> from http import HTTPStatus
+ >>> HTTPStatus.OK.is_success
+ True
+ >>> HTTPStatus.OK.is_client_error
+ False
+
.. class:: HTTPMethod
.. versionadded:: 3.11