From e43420f15b76f7a477c8a3c02a70ad90a0f7bf77 Mon Sep 17 00:00:00 2001 From: "Michiel W. Beijen" Date: Wed, 8 Jul 2026 09:05:30 +0200 Subject: [PATCH 1/6] Add HTTP QUERY method (RFC 10008) to http library Closes #153309 --- Doc/library/http.rst | 2 ++ Lib/http/__init__.py | 2 ++ Lib/wsgiref/validate.py | 2 +- .../next/Library/2026-07-08-09-05-01.gh-issue-153309.g94LSO.rst | 1 + 4 files changed, 6 insertions(+), 1 deletion(-) create mode 100644 Misc/NEWS.d/next/Library/2026-07-08-09-05-01.gh-issue-153309.g94LSO.rst diff --git a/Doc/library/http.rst b/Doc/library/http.rst index 43a801416e24f99..2520c9718aed6c6 100644 --- a/Doc/library/http.rst +++ b/Doc/library/http.rst @@ -194,6 +194,7 @@ Property Indicates that Details , , , + , ] .. _http-methods: @@ -217,4 +218,5 @@ Method Enum Name Details ``OPTIONS`` ``OPTIONS`` HTTP Semantics :rfc:`9110`, Section 9.3.7 ``TRACE`` ``TRACE`` HTTP Semantics :rfc:`9110`, Section 9.3.8 ``PATCH`` ``PATCH`` HTTP/1.1 :rfc:`5789` +``QUERY`` ``QUERY`` The HTTP QUERY Method :rfc:`10008` =========== =================================== ================================================================== diff --git a/Lib/http/__init__.py b/Lib/http/__init__.py index 691b4a9a367bd0f..b30cfbb9229b3e0 100644 --- a/Lib/http/__init__.py +++ b/Lib/http/__init__.py @@ -192,6 +192,7 @@ class HTTPMethod: * RFC 9110: HTTP Semantics, obsoletes 7231, which obsoleted 2616 * RFC 5789: PATCH Method for HTTP + * RFC 10008: The HTTP QUERY Method """ def __new__(cls, value, description): obj = str.__new__(cls, value) @@ -210,4 +211,5 @@ def __repr__(self): PATCH = 'PATCH', 'Apply partial modifications to a target.' POST = 'POST', 'Perform target-specific processing with the request payload.' PUT = 'PUT', 'Replace the target with the request payload.' + QUERY = 'QUERY', 'Query the target with the request payload.' TRACE = 'TRACE', 'Perform a message loop-back test along the path to the target.' diff --git a/Lib/wsgiref/validate.py b/Lib/wsgiref/validate.py index 1a1853cd63a0d2a..cc572e8a179d1eb 100644 --- a/Lib/wsgiref/validate.py +++ b/Lib/wsgiref/validate.py @@ -334,7 +334,7 @@ def check_environ(environ): # @@: these need filling out: if environ['REQUEST_METHOD'] not in ( - 'GET', 'HEAD', 'POST', 'OPTIONS', 'PATCH', 'PUT', 'DELETE', 'TRACE'): + 'GET', 'HEAD', 'POST', 'OPTIONS', 'PATCH', 'PUT', 'DELETE', 'QUERY', 'TRACE'): warnings.warn( "Unknown REQUEST_METHOD: %r" % environ['REQUEST_METHOD'], WSGIWarning) diff --git a/Misc/NEWS.d/next/Library/2026-07-08-09-05-01.gh-issue-153309.g94LSO.rst b/Misc/NEWS.d/next/Library/2026-07-08-09-05-01.gh-issue-153309.g94LSO.rst new file mode 100644 index 000000000000000..97fbc7ea4b5cb43 --- /dev/null +++ b/Misc/NEWS.d/next/Library/2026-07-08-09-05-01.gh-issue-153309.g94LSO.rst @@ -0,0 +1 @@ +Add the HTTP QUERY method (RFC 10008) to http.HTTPMethod. From 31e18ad4b03e0556d7dad1405993d5b3b73b4c23 Mon Sep 17 00:00:00 2001 From: "Michiel W. Beijen" Date: Wed, 8 Jul 2026 11:50:13 +0200 Subject: [PATCH 2/6] Add QUERY to methods that expect a body --- Doc/library/http.client.rst | 2 +- Lib/http/client.py | 2 +- Lib/test/test_httplib.py | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Doc/library/http.client.rst b/Doc/library/http.client.rst index 98ea09d8f72d8b6..2ff2817590f9921 100644 --- a/Doc/library/http.client.rst +++ b/Doc/library/http.client.rst @@ -289,7 +289,7 @@ HTTPConnection Objects but there is a request body, one of those header fields will be added automatically. If *body* is ``None``, the Content-Length header is set to ``0`` for - methods that expect a body (``PUT``, ``POST``, and ``PATCH``). If + methods that expect a body (``PUT``, ``POST``, ``PATCH``, and ``QUERY``). If *body* is a string or a bytes-like object that is not also a :term:`file `, the Content-Length header is set to its length. Any other type of *body* (files diff --git a/Lib/http/client.py b/Lib/http/client.py index 7ef99e7201c005c..aafd3c55166d94f 100644 --- a/Lib/http/client.py +++ b/Lib/http/client.py @@ -167,7 +167,7 @@ # We always set the Content-Length header for these methods because some # servers will otherwise respond with a 411 -_METHODS_EXPECTING_BODY = {'PATCH', 'POST', 'PUT'} +_METHODS_EXPECTING_BODY = {'PATCH', 'POST', 'PUT', 'QUERY'} def _encode(data, name='data'): diff --git a/Lib/test/test_httplib.py b/Lib/test/test_httplib.py index 5b1d6e0aa520794..abd21ef215a27c1 100644 --- a/Lib/test/test_httplib.py +++ b/Lib/test/test_httplib.py @@ -179,7 +179,7 @@ def append(self, item): # Here, we're testing that methods expecting a body get a # content-length set to zero if the body is empty (either None or '') bodies = (None, '') - methods_with_body = ('PUT', 'POST', 'PATCH') + methods_with_body = ('PUT', 'POST', 'PATCH', 'QUERY') for method, body in itertools.product(methods_with_body, bodies): conn = client.HTTPConnection('example.com') conn.sock = FakeSocket(None) From b61eb5002ef92f3005e8e433cddd8439033625ff Mon Sep 17 00:00:00 2001 From: "Michiel W. Beijen" Date: Wed, 8 Jul 2026 12:34:17 +0200 Subject: [PATCH 3/6] Update Lib/http/__init__.py Co-authored-by: Eduardo Villalpando Mello --- Lib/http/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Lib/http/__init__.py b/Lib/http/__init__.py index b30cfbb9229b3e0..219b3d1355b7294 100644 --- a/Lib/http/__init__.py +++ b/Lib/http/__init__.py @@ -211,5 +211,5 @@ def __repr__(self): PATCH = 'PATCH', 'Apply partial modifications to a target.' POST = 'POST', 'Perform target-specific processing with the request payload.' PUT = 'PUT', 'Replace the target with the request payload.' - QUERY = 'QUERY', 'Query the target with the request payload.' + QUERY = 'QUERY', 'Request that the target process the request payload in a safe and idempotent manner.' TRACE = 'TRACE', 'Perform a message loop-back test along the path to the target.' From 62306548d8f10facb67f2c38198c44b44678fc3d Mon Sep 17 00:00:00 2001 From: "Michiel W. Beijen" Date: Wed, 8 Jul 2026 22:26:02 +0200 Subject: [PATCH 4/6] Use :rfc: role in news entry for linking --- .../next/Library/2026-07-08-09-05-01.gh-issue-153309.g94LSO.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Misc/NEWS.d/next/Library/2026-07-08-09-05-01.gh-issue-153309.g94LSO.rst b/Misc/NEWS.d/next/Library/2026-07-08-09-05-01.gh-issue-153309.g94LSO.rst index 97fbc7ea4b5cb43..7da9363bf2e9672 100644 --- a/Misc/NEWS.d/next/Library/2026-07-08-09-05-01.gh-issue-153309.g94LSO.rst +++ b/Misc/NEWS.d/next/Library/2026-07-08-09-05-01.gh-issue-153309.g94LSO.rst @@ -1 +1 @@ -Add the HTTP QUERY method (RFC 10008) to http.HTTPMethod. +Add the HTTP QUERY method (:rfc:`10008`) to http.HTTPMethod. From ce60033595d7cdbe88199cf02273de55396b426a Mon Sep 17 00:00:00 2001 From: "Michiel W. Beijen" Date: Wed, 8 Jul 2026 22:28:45 +0200 Subject: [PATCH 5/6] In news entry, also link to HTTPMethod doc --- .../next/Library/2026-07-08-09-05-01.gh-issue-153309.g94LSO.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Misc/NEWS.d/next/Library/2026-07-08-09-05-01.gh-issue-153309.g94LSO.rst b/Misc/NEWS.d/next/Library/2026-07-08-09-05-01.gh-issue-153309.g94LSO.rst index 7da9363bf2e9672..7cb1527e5fbc85f 100644 --- a/Misc/NEWS.d/next/Library/2026-07-08-09-05-01.gh-issue-153309.g94LSO.rst +++ b/Misc/NEWS.d/next/Library/2026-07-08-09-05-01.gh-issue-153309.g94LSO.rst @@ -1 +1 @@ -Add the HTTP QUERY method (:rfc:`10008`) to http.HTTPMethod. +Add the HTTP QUERY method (:rfc:`10008`) to :class:`http.HTTPMethod`. From b7c9a20a217ab945b0a4c07f52082b1862c06d8e Mon Sep 17 00:00:00 2001 From: "Michiel W. Beijen" Date: Thu, 9 Jul 2026 11:11:32 +0200 Subject: [PATCH 6/6] whatsnew, versionchanged, better NEWS --- Doc/library/http.client.rst | 3 +++ Doc/whatsnew/3.16.rst | 7 +++++++ .../Library/2026-07-08-09-05-01.gh-issue-153309.g94LSO.rst | 2 +- 3 files changed, 11 insertions(+), 1 deletion(-) diff --git a/Doc/library/http.client.rst b/Doc/library/http.client.rst index 2ff2817590f9921..12868c18c416512 100644 --- a/Doc/library/http.client.rst +++ b/Doc/library/http.client.rst @@ -335,6 +335,9 @@ HTTPConnection Objects No attempt is made to determine the Content-Length for file objects. + .. versionchanged:: next + ``QUERY`` was added to the methods that expect a body. + .. method:: HTTPConnection.getresponse() Should be called after a request is sent to get the response from the server. diff --git a/Doc/whatsnew/3.16.rst b/Doc/whatsnew/3.16.rst index e871ad822bbcedc..6145d71499140e7 100644 --- a/Doc/whatsnew/3.16.rst +++ b/Doc/whatsnew/3.16.rst @@ -229,6 +229,13 @@ gzip which is passed on to the constructor of the :class:`~gzip.GzipFile` class. (Contributed by Marin Misur in :gh:`91372`.) + +http +---- + +* Add the ``QUERY`` HTTP method (:rfc:`10008`) to :class:`~http.HTTPMethod`. + (Contributed by Michiel W. Beijen in :gh:`153309`.) + io -- diff --git a/Misc/NEWS.d/next/Library/2026-07-08-09-05-01.gh-issue-153309.g94LSO.rst b/Misc/NEWS.d/next/Library/2026-07-08-09-05-01.gh-issue-153309.g94LSO.rst index 7cb1527e5fbc85f..9245c1442b06f87 100644 --- a/Misc/NEWS.d/next/Library/2026-07-08-09-05-01.gh-issue-153309.g94LSO.rst +++ b/Misc/NEWS.d/next/Library/2026-07-08-09-05-01.gh-issue-153309.g94LSO.rst @@ -1 +1 @@ -Add the HTTP QUERY method (:rfc:`10008`) to :class:`http.HTTPMethod`. +:mod:`http`: Add the HTTP QUERY method (:rfc:`10008`) to :class:`~http.HTTPMethod`.