summaryrefslogtreecommitdiffstats
path: root/Lib/http
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 /Lib/http
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 'Lib/http')
-rw-r--r--Lib/http/__init__.py20
1 files changed, 20 insertions, 0 deletions
diff --git a/Lib/http/__init__.py b/Lib/http/__init__.py
index cd2885d..e093a1f 100644
--- a/Lib/http/__init__.py
+++ b/Lib/http/__init__.py
@@ -31,6 +31,26 @@ class HTTPStatus:
obj.description = description
return obj
+ @property
+ def is_informational(self):
+ return 100 <= self <= 199
+
+ @property
+ def is_success(self):
+ return 200 <= self <= 299
+
+ @property
+ def is_redirection(self):
+ return 300 <= self <= 399
+
+ @property
+ def is_client_error(self):
+ return 400 <= self <= 499
+
+ @property
+ def is_server_error(self):
+ return 500 <= self <= 599
+
# informational
CONTINUE = 100, 'Continue', 'Request received, please continue'
SWITCHING_PROTOCOLS = (101, 'Switching Protocols',