[Python-checkins] bpo-39507: Add HTTP status 418 "I'm a Teapot" (GH-18291)

Ross webhook-mailer at python.org
Sun Mar 15 08:24:33 EDT 2020


https://github.com/python/cpython/commit/61ac612e78e4f2625977406fb6f366e0a644673a
commit: 61ac612e78e4f2625977406fb6f366e0a644673a
branch: master
author: Ross <rrhodes at users.noreply.github.com>
committer: GitHub <noreply at github.com>
date: 2020-03-15T14:24:23+02:00
summary:

bpo-39507: Add HTTP status 418 "I'm a Teapot" (GH-18291)

files:
A Misc/NEWS.d/next/Library/2020-01-31-14-24-05.bpo-39507.3oln1a.rst
M Doc/library/http.rst
M Doc/whatsnew/3.9.rst
M Lib/http/__init__.py
M Lib/test/test_httplib.py

diff --git a/Doc/library/http.rst b/Doc/library/http.rst
index f120ada2091b5..14ee73363e62e 100644
--- a/Doc/library/http.rst
+++ b/Doc/library/http.rst
@@ -99,6 +99,7 @@ Code    Enum Name                           Details
 ``415`` ``UNSUPPORTED_MEDIA_TYPE``          HTTP/1.1 :rfc:`7231`, Section 6.5.13
 ``416`` ``REQUESTED_RANGE_NOT_SATISFIABLE`` HTTP/1.1 Range Requests :rfc:`7233`, Section 4.4
 ``417`` ``EXPECTATION_FAILED``              HTTP/1.1 :rfc:`7231`, Section 6.5.14
+``418`` ``IM_A_TEAPOT``                     HTCPCP/1.0 :rfc:`2324`, Section 2.3.2
 ``421`` ``MISDIRECTED_REQUEST``             HTTP/2 :rfc:`7540`, Section 9.1.2
 ``422`` ``UNPROCESSABLE_ENTITY``            WebDAV :rfc:`4918`, Section 11.2
 ``423`` ``LOCKED``                          WebDAV :rfc:`4918`, Section 11.3
@@ -134,4 +135,4 @@ equal to the constant name (i.e. ``http.HTTPStatus.OK`` is also available as
    Added ``451 UNAVAILABLE_FOR_LEGAL_REASONS`` status code.
 
 .. versionadded:: 3.9
-   Added ``103 EARLY_HINTS`` and ``425 TOO_EARLY`` status codes.
+   Added ``103 EARLY_HINTS``, ``418 IM_A_TEAPOT`` and ``425 TOO_EARLY`` status codes.
diff --git a/Doc/whatsnew/3.9.rst b/Doc/whatsnew/3.9.rst
index b078e7917765b..12e3f18408d4f 100644
--- a/Doc/whatsnew/3.9.rst
+++ b/Doc/whatsnew/3.9.rst
@@ -235,8 +235,8 @@ finalized by the garbage collector. (Contributed by Pablo Galindo in
 http
 ----
 
-HTTP status codes ``103 EARLY_HINTS`` and ``425 TOO_EARLY`` are added to
-:class:`http.HTTPStatus`. (Contributed by Dong-hee Na in :issue:`39509`.)
+HTTP status codes ``103 EARLY_HINTS``, ``418 IM_A_TEAPOT`` and ``425 TOO_EARLY`` are added to
+:class:`http.HTTPStatus`. (Contributed by Dong-hee Na in :issue:`39509` and Ross Rhodes in :issue:`39507`.)
 
 imaplib
 -------
diff --git a/Lib/http/__init__.py b/Lib/http/__init__.py
index c8498be0de20d..37be765349ea0 100644
--- a/Lib/http/__init__.py
+++ b/Lib/http/__init__.py
@@ -17,6 +17,7 @@ class HTTPStatus(IntEnum):
         * RFC 2774: An HTTP Extension Framework
         * RFC 7725: An HTTP Status Code to Report Legal Obstacles
         * RFC 7540: Hypertext Transfer Protocol Version 2 (HTTP/2)
+        * RFC 2324: Hyper Text Coffee Pot Control Protocol (HTCPCP/1.0)
         * RFC 8297: An HTTP Status Code for Indicating Hints
         * RFC 8470: Using Early Data in HTTP
     """
@@ -103,6 +104,8 @@ def __new__(cls, value, phrase, description=''):
         'Cannot satisfy request range')
     EXPECTATION_FAILED = (417, 'Expectation Failed',
         'Expect condition could not be satisfied')
+    IM_A_TEAPOT = (418, 'I\'m a Teapot',
+        'Server refuses to brew coffee because it is a teapot.')
     MISDIRECTED_REQUEST = (421, 'Misdirected Request',
         'Server is not able to produce a response')
     UNPROCESSABLE_ENTITY = 422, 'Unprocessable Entity'
diff --git a/Lib/test/test_httplib.py b/Lib/test/test_httplib.py
index 7f4decc8fda03..77d43359f3026 100644
--- a/Lib/test/test_httplib.py
+++ b/Lib/test/test_httplib.py
@@ -1433,6 +1433,7 @@ def test_client_constants(self):
             'UNSUPPORTED_MEDIA_TYPE',
             'REQUESTED_RANGE_NOT_SATISFIABLE',
             'EXPECTATION_FAILED',
+            'IM_A_TEAPOT',
             'MISDIRECTED_REQUEST',
             'UNPROCESSABLE_ENTITY',
             'LOCKED',
diff --git a/Misc/NEWS.d/next/Library/2020-01-31-14-24-05.bpo-39507.3oln1a.rst b/Misc/NEWS.d/next/Library/2020-01-31-14-24-05.bpo-39507.3oln1a.rst
new file mode 100644
index 0000000000000..6d49dabd38d0b
--- /dev/null
+++ b/Misc/NEWS.d/next/Library/2020-01-31-14-24-05.bpo-39507.3oln1a.rst
@@ -0,0 +1 @@
+Adding HTTP status 418 "I'm a Teapot" to HTTPStatus in http library. Patch by Ross Rhodes.
\ No newline at end of file



More information about the Python-checkins mailing list