Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion Doc/library/http.client.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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 <file object>`, the Content-Length header is
set to its length. Any other type of *body* (files
Expand Down Expand Up @@ -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.
Expand Down
2 changes: 2 additions & 0 deletions Doc/library/http.rst
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,7 @@ Property Indicates that Details
<HTTPMethod.PATCH>,
<HTTPMethod.POST>,
<HTTPMethod.PUT>,
<HTTPMethod.QUERY>,
<HTTPMethod.TRACE>]

.. _http-methods:
Expand All @@ -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`
=========== =================================== ==================================================================
7 changes: 7 additions & 0 deletions Doc/whatsnew/3.16.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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
--

Expand Down
2 changes: 2 additions & 0 deletions Lib/http/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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', '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.'
2 changes: 1 addition & 1 deletion Lib/http/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -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'):
Expand Down
2 changes: 1 addition & 1 deletion Lib/test/test_httplib.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion Lib/wsgiref/validate.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
:mod:`http`: Add the HTTP QUERY method (:rfc:`10008`) to :class:`~http.HTTPMethod`.
Loading